Saturday, October 12, 2013

WAP to input 3 sides of triangle and check whether it is valid or not


#include<conio.h>
#include<stdio.h>
#include<math.h>
int main()
{
float a,b,c,s,A;
printf("\n enter the value of the sides of the triangle:");
scanf("%f%f%f",&a,&b,&c);
if( (a+b>c) && (b+c>a) && (a+c>b) )
{
s=(a+b+c)/2;
A=sqrt(s*(s-a)*(s-b)*(s-c));
printf("\n the triangle is valid");
printf("\n the area of the triangle is:%f",A);
}
else
printf("\n the triangle is not valid");
getch();
return 0;
}

No comments:

Post a Comment