C program to check triangle is valid or not if the sides are given
In this program, you will take input of three sides from the user and you will check whether the triangle is valid or not if sides are given, if the sum of any two sides is greater than the third side then a triangle is valid
check triangle is valid or not if the sides are given using if else
#include <stdio.h>
int main()
{
int side1,side2,side3;
printf("\n enter three side of triangle:");
scanf("%d %d %d",&side1,&side2,&side3);
if((side1+side2>side3)&&(side1+side3>side2)&&(side2+side3>side1))
{
printf("tringle is valid");
}
else
{
printf("triangle is not valid");
}
return 0;
}
output
enter three side of triangle:3 5 7 triangle is valid
logic for checking triangle is valide or not
input three triangle side from the user and check if sum of all the two side is greater than third side than triangle is valid
side1+side2>side3
side2+side3>side1
side1+side3>side2
if all these condition satisfy than triangle is valid