Pages

This blog is under construction

Thursday, December 20, 2018

C program to compute the area of the triangle using heron's formula.

Heron's formula
A=sqrt(S(S-a)(S-b)(S-c))
Where a, b and c are sides of the triangle and S=(a+b+c)/2.

#include<stdio.h>
#include<math.h>
void main()
{
int a,b,c;
float S,Area;
a=b=c=S=0;
a=20;
b=30;
c=40;
S=(a+b+c)/2;
Area=sqrt(S*(S-a)*(S-b)*(S-c));
printf("Area of a triangle is= %f",Area);
}

Area of a triangle is= 290.473755

No comments:

Post a Comment