C Program to check valid triangle using nested if
#include<stdio.h>
int main()
{
int side1, side2, side3;
/* Initially assume that the triangle is not valid then create a Flag*/
int flag = 1;
printf("Enter three side of Triangle: ");
scanf("%d%d%d",&side1,&side2,&side3);
if((side1 + side2) > side3 )
{
if((side2 + side3) > side1)
{
if((side1 + side3) > side2)
{
/* If all condiction is satisfied then flag is true or 1 */
flag = 1;
}
}
}
if(flag == 1)
{
printf("Triangle is Valid");
}
/* If Flag is 0 or Flase */
else
{
printf("Invalid Triangle");
}
return 0;
}
Output
Enter three side of Triangle: 10
12
15
Triangle is Valid