Area of a triangle given as follows: A= square root of s(s-a)(s-b)(s-c) where a,b,c are the sides of a triangle and 2s=a+b+c. Write a C program to calculate the area of a triangle.
Answer:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void
main()
{
clrscr();
float
a,b,c,S,A;
printf("ENTER THE
THREE SIDES OF A TRIANGLE: ");
scanf("%f%f%f",&a,&b,&c);
S=(a+b+c)/2;
A=sqrt(S*(S-a)*(S-b)*(S-c));
printf("\nArea of
the triangle: %.2f",A);
getch();
}
Sample output:
ENTER THE THREE SIDES
OF A TRIANGLE: 10 12 14
Area of the triangle=58.79