Thursday 25 July 2013

Chapter 2 solutions Problem [F][f]

Question-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.
Solution-
Basic problem. Here is the solution.

#include<stdio.h>
int main()
{
float a,b,c;
printf("Enter the length of sides\n");
scanf("%f%f%f",&a,&b,&c);
if(a+b>c||b+c>a||c+a>b)
printf("Valid Traingle\n");
else
printf("Not a Valid Traingle\n");
return 0;
}

No comments:

Post a Comment