/*program
to read three numbers from the key board and print the area of triangle by
using function*/

#include<math.h>

float
triangle(float,float,float,float,float);

void main()

{

float
s,a,b,c,ar;

clrscr();

printf("Enter
three values for triangle ");

scanf("%f%f%f",&a,&b,&c);

triangle(a,b,c,s,ar);

//if(r==0)

getch();

}

float
triangle(float a,float b,float c,float s,float ar)

{

if(c>a&&c>b&&a+b>c||b>a&&b>c&&a+c>b||a>b&&a>c&&b+c>a)

{

s=((a+b+c)/2);

ar=sqrt(s*(s-a)*(s-b)*(s-c));

printf("\nThe
area of triangle is %f",ar);

}

else

printf("\nSORRY
try again, triangle of this measurement doesn’t exist ");

return 0;

}

**Output**

Enter three
values for triangle 3 4 5

The area of
triangle is 6.000000

Or

Enter three
values for triangle 2 5 8

SORRY try again,
triangle of this measurement doesn’t exist

## No comments:

## Post a Comment