Amazon Interview Question Software Engineer in Tests


Country: India
Interview Type: Phone Interview


Comment hidden because of low score. Click to expand.
2
of 2 vote

following are the test cases.. in case ny missing please point out
1.length zero not acceptable for ny of the side
2.should return scalene if a!=b!=c.
3.should return equilateral if a=b=c
4.should return isosceles if any two are equal.
5.negative edges not allowed.

- rockstar on July 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

and sum of two edges should be greater than third one.

- Curious on July 19, 2012 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 votes

Adding couple of other cases:

1. Length of sides are 0,0, 0 : No triangle Should be made
2. Length of sides are -1, -1, -1 : No triangle Should be made with -ve values
3. Length of sides are 1, 0,X : no triangle can be made . only
numbers and no alphabets are accepted
4. Do not enter any values : Prompt to enter valid values
5. By entering the low and high end values 0.00001 , 100000,1000000 : Triangle should be made (Boundary value analysis)
6. The Summation of 2 sides should always greater than third value. Ex: 1,2,4 are the lenghths then - 1+2<4 . So
triangle can not be made

7. Length of all sides are equal : Equilateral triangle
8. Two sides length are equal : Isoscelous triangle
9. All lengths are unequal: Scalene triangle
10. Test with very small values , very large values and
combinations of both.

- ravgvn on July 19, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 4 vote

if(a<=0 || b<=0 || c<=0 || a+b<=c || a+c<=b || b+c<=a)
	cout << "Error";
else if(a==b && b==c)
	cout << "Equilateral";
else if(a==b || b==c || a==c)
	cout << "Isosceles";
else
	cout << "Scalene";

- Anonymous on July 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

if(a==null || b==null || c==null)
cout<<"any of sides must not be null";

else if(a<=0 || b<=0 || c<=0 || a+b<=c || b+c<=a || c+a<=0)
cout<<"sides must be +ve numbers and sum of two sides must be greater than the third one";

else if(a==b && b!=c)
cout<<"isosceles triangle";

else if(a==b && b==c)
cout<<"equilateral triangle";

else if(a!=b && a!=c && c!=a)
cout<<"scalene";

else
cout<<"sides must not be alphabates, special chars";

- Venkat on July 21, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book walking you through getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More