C program to Find Area of the triangle

Here is the C program to find Area of triangle where user should input three sides a,b and c





#include<stdio.h>
#include<math.h>
main()
{
float s,a,b,c,A;
printf("Enter Sides of triangle (1st,2nd,3rd)=");
scanf("%f%f%f",&a,&b,&c);
s=(a+b+c)/2;                                                              // finding semiperimeter
A=sqrt(s*(s-a)*(s-b)*(s-c));                                      //formula to calculate the area
printf("Area of triangle = %f\n",A);                           //Printing Area
}

Output will be as


Post a Comment

0 Comments