If the three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is valid or not. The triangle is valid if the sum of two sides is greater than the largest of the three sides.
void main()
{
float a,b,c,biggest;
printf("\nEnter the length of 3 sides of the triangle");
scanf("%f%f%f",&a,&b,&c);
biggest=(a>b?(a>c?a:c):(b>c?b:c));
if (biggest==a)
{
if(b+c>a)
printf("\nThe triangle is valid");
else
printf("\nThe triangle is invalid");
}
else if (biggest==b)
{
if(a+c>b)
printf("\nThe triangle is valid");
else
printf("\nThe triangle is invalid");
}
else
{
if(a+b>c)
printf("\nThe triangle is valid");
else
printf("\nThe triangle is invalid");
}
}
Subscribe to:
Post Comments (Atom)
Thanks
ReplyDeletemany thanks
ReplyDeleteprogram is large
ReplyDelete非常に良い、それを維持する
ReplyDeletethanks
ReplyDeleteThank you man!! exactly what i was looking for
ReplyDelete