Microsoft
3.6 of 5 7,024 reviews
www.microsoft.com Redmond, WA 5000+ Employees

Microsoft Software Development Engineer In Test (SDET) Interview Question

I interviewed in Redmond, WA and was asked:
"Given a triangle, determine if its a scalene, equilateral, isosceles or neither... required knowledge of triangle properties, I learnt these properties about two decades ago so ofcourse I was fuzzy on the details, completely unexpected"
Add Tags [?]
Answer Flag Question

Part of a Software Development Engineer In Test (SDET) Interview Review - one of 3,166 Microsoft Interview Reviews

Answers & Comments

0
of 0
votes
testing use of ==, got a feeling he wanted to use bit level comparisons to compare sides lengths
- Interview Candidate on Feb 19, 2013 Flag Response
0
of 0
votes
If the sides are all integers, then compare the length^2 instead of length to avoid the floating comparison;

If the sides are floating numbers, then we need to set an epsilon to test.

You'd better ask the interviewer about this. Asking this will definitely gives the interviewer better impression.... I believe :-)
- Peter on Jul 21, 2013 Flag Response
0
of 0
votes
BTW, if you are given the sides instead of points, the condition to make an triangle is:

a+b > c && b+c > a && c+a > b
- Peter on Jul 21, 2013 Flag Response
1
of 1
vote
/* Q: Given a, b, c, determine if it can be the 3 sides of triangles, if yes
      determine if it's equilateral, isosceles, or scalene. */

#include <iostream>
#include <string>
#include <cmath>
using namespace std;

// Use this in real world
typedef enum
{
    NONE = 0,
    EQUILATERAL = 1,
    ISOCELES = 2,
    SCALENE = 3
} TriangleType;

double Epsilon = 1.0E-6;

string GetTriangleType(double a, double b, double c)
{
    if (a+b > c && b+c > a && c+a > b)
    {
        bool ab = (fabs(a-b) < Epsilon);
        bool bc = (fabs(b-c) < Epsilon);
        bool ca = (fabs(c-a) < Epsilon);

        if (ab && bc && ca)
            return "Equilateral";

        if (ab || bc || ca)
            return "Isoceles";

        return "Scalene";
    }
    else
    {
        return "None";
    }
}

int main()
{
    cout << GetTriangleType(3, 3, 3) << endl;
    cout << GetTriangleType(3, 3, 5) << endl;
    cout << GetTriangleType(3, 4, 5) << endl;
    cout << GetTriangleType(3, 4, 7) << endl;

    return 0;
}
/* Output:
Equilateral
Isoceles
Scalene
None
 */
- Peter on Jul 21, 2013 Flag Response

To comment on this question, Sign In with Facebook or Sign Up


Tags are like keywords, helping to categorise interview questions that have something in common.

Glassdoor is your free inside look at Microsoft interview questions and advice. All interview reviews are posted anonymously by Microsoft employees and interview candidates.