Skip to content

Commit 25f5050

Browse files
Update TriangleEverywhere.cpp
1 parent 6bb85fd commit 25f5050

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1+
/* You're given the length of three sides a, b, and c respectively.
2+
Now If these three sides can form an Equilateral Triangle then print 1, if these three sides can form an Isosceles Triangle then print 2,
3+
if these three sides can form a Scalene Triangle then print 3, otherwise print −1.*/
4+
5+
16
#include <iostream>
27
using namespace std;
38

49
int main()
510
{
6-
int a, b, c;
7-
cin >> a >> b >> c;
8-
if (a + b > c && b + c > a && c + a > b)
11+
int a, b, c;
12+
cin >> a >> b >> c;
13+
if (a + b > c && b + c > a && c + a > b) // condition for a triangle.
914
{
10-
if (a == b && b == c)
15+
if (a == b && b == c) // condition for equilateral triangle.
1116
cout << "1";
12-
else if (a == b || b == c || c == a)
17+
else if (a == b || b == c || c == a) // condition for isosceles triangle.
1318
cout << "2";
1419
else
15-
cout << "3";
20+
cout << "3";
1621
}
1722
else
18-
cout << "-1";
23+
cout << "-1";
1924
return 0;
2025
}

0 commit comments

Comments
 (0)