ProAnswers.org

Write a C program to accept three sides of a triangle and transfer them to a function to compute the area of a triangle

Write a program to accept three sides of a triangle and transfer them to a function to compute the area of a triangle.

#include /header file/
#include /header file/
float tri_area(float a,float b, float c); /* new function*/
main() /main function/
{
{
float s1,s2,s3,area;
printf(“
Enter the three sides of a triangle”);
scanf(“%f%f%f”,&s1,&s2,&s3);
area=tri_area(s1,s2,s3);
printf(“
Area of triangle is : %f square units.”, area); /printing area/
}
float tri_area(float a,float b,float c)
{
float s, area;
s=(a+b+c)/2;
area=sqrt(s*(s-a)(s-b)(s-c)); /hero’s formula/
return(area);
}
}