Learn about C Program to find Area of a triangle having three sides in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
C Program to find Area of a triangle having three sides
The triangle’s three sides are a, b, and c. To obtain the square root value, we utilised the sqrt() function. sqrt() is a math function. The program displays the area of the given sides of the triangle.
Program:
#include<stdio.h>
#include<math.h>
int main()
{
// variables declaration
float a, b, c, s, area;
// inputs from user
printf("Enter a,b and c value: ");
scanf("%f %f %f",&a,&b,&c);
// calculating area
s = (a+b+c)/2;
area = sqrt( s*(s-a)*(s-b)*(s-c) );
// print result
printf("Area = %.2f\n",area);
return 0;
}
Output:
Enter a,b and c value: 3 4 5
Area = 6.00
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
C program to find the area of a Rectangle
C program to find Area of a Circle Using Symbolic Constant