Area of a Triangle

Write a c program to find the area of a triangle

Formula for area of any triangle:

Area = √(s*(s-a)*(s-b)*(s-c))
Where s = (a + b + c)/2

#include<stdio.h>
#include<math.h>

int main(){

float a,b,c;
float s,area;

printf("Enter size of each sides of triangle");
scanf("%f%f%f",&amp;amp;a,&amp;amp;b,&amp;amp;c);

s = (a+b+c)/2;
area = sqrt(s*(s-a)*(s-b)*(s-c));

printf("Area of triangle is: %.3f",area);

return 0;
}

Output:

Enter size of each sides of the triangle: 2 4 5
Area of triangle is: 3.800


Comments

Leave a Reply