1/**
2 * C program to check whether a triangle is valid or not if its sides are given
3 */
4
5#include <stdio.h>
6
7int main()
8{
9 int side1, side2, side3;
10
11 /* Input three sides of a triangle */
12 printf("Enter three sides of triangle: \n");
13 scanf("%d%d%d", &side1, &side2, &side3);
14
15 if((side1 + side2) > side3)
16 {
17 if((side2 + side3) > side1)
18 {
19 if((side1 + side3) > side2)
20 {
21 /*
22 * If side1 + side2 > side3 and
23 * side2 + side3 > side1 and
24 * side1 + side3 > side2 then
25 * the triangle is valid.
26 */
27 printf("Triangle is valid.");
28 }
29 else
30 {
31 printf("Triangle is not valid.");
32 }
33 }
34 else
35 {
36 printf("Triangle is not valid.");
37 }
38 }
39 else
40 {
41 printf("Triangle is not valid.");
42 }
43
44 return 0;
45}
1/*
2 formula is : any of 2 side is must be bigger than the third side of a triangle.
3 */
4#include <stdio.h>
5int main()
6{
7 double side1, side2, side3;
8 scanf("%lf %lf %lf", &side1, &side2, &side3);
9
10 if (side1 + side2 > side3 && side2 + side3 > side1 && side1 + side3 > side2) // applying formula
11 {
12 printf("Yes. It can be a triangle\n");
13 }
14 else
15 {
16 printf("Yes. It can't be a triangle\n");
17 }
18 return 0;
19}