Skip to content

Commit f125d72

Browse files
authored
Create Valid traingle or not.c
1 parent c3af0a1 commit f125d72

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* You're given the length of three sides a, b, and c respectively. Now check if these three sides can form a triangle or not. Print "YES"(without quotes) if it can form a valid triangle with an area greater than 0, otherwise print "NO" (without quotes).
2+
3+
Input:
4+
First-line will contain three numbers a, b, and c separated by space.
5+
Output:
6+
Print "YES"(without quotes) if these sides can form a valid triangle, otherwise print "NO" (without quotes).
7+
8+
Constraints
9+
1≤a,b,c≤106
10+
Sample Input 1:
11+
2 4 3
12+
Sample Output 1:
13+
YES
14+
Sample Input 2:
15+
1 1 4
16+
Sample Output 2:
17+
NO
18+
EXPLANATION:
19+
In the first example, (2, 4, 3) can form a triangle with an area greater than 0.
20+
In the second example, (1, 1, 4) will never form a valid triangle. */
21+
22+
#include <stdio.h>
23+
#include <math.h>
24+
25+
int main(void) {
26+
27+
int s1,s2,s3;
28+
scanf("%d %d %d",&s1,&s2,&s3);
29+
30+
if(((s1+s2)>s3)&&((s2+s3)>s1)&&((s1+s3)>s2))
31+
{
32+
printf("YES");
33+
}
34+
else
35+
{
36+
printf("NO");
37+
}
38+
return 0;
39+
}

0 commit comments

Comments
 (0)