In the following code i have included the math library as well because the use of square root function was required . There are plenty others functions located in the math library .Dont forget to write –lm while compiling as it is required for math library if ur working on linux environment eg gcc test.c –lm . Anyways here is the code as the topic says
#include<stdio.h>
#include<math.h>
int main ()
{
float a,b,c,s,area;
printf("\nENTER THE THREE SIDES OF TRIANGLE\n");
scanf("%f%f%f",&a,&b,&c);
if( ((a+b)>c) && ((a+c)>b) && ((b+c)>a))
{
if ((a==b) && (a==c))
{printf("\nEQUILATERAL TRIANGLE\n");}
else
{
if((a==b) || (a==c) || (b==c) )
printf("\nISOCELES TRIANGLE\n");
else
printf("\nSCALENE TRIANLGE\n");
}
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("AREA IS %.2f sq units\n",area);
}
else
{printf("TRIANGLE NOT POSSIBLE");}
retur
No comments:
Post a Comment