Problem
Write a function that takes three integers corresponding to the lengths of sides and returns what kind of triangle can be made out of those 3 sides. (Equilateral, etc)You must also handle the case where no triangle may be formed from those 3 lengths.
Solution
We have to do followingif(2 sides greater than 1){ if(a==b && b==c) // all sides equal "Equilateral triangle\n"; else if(a==b || a==c || b==c) // at least 2 sides equal "Isosceles triangle\n"; else // no sides equal "Scalene triangle\n"; }else "Not a triangle";
Thanks.
0 comments:
Post a Comment