21. C Program To find Area of Triangle if 3 sides are given.
How does this program work?
- In this program you are going to learn about How to find out the Area of triangle if 3sides are given C language.
- Take User inputs for lengths of 3sides of a triangle.
- And Store them in variables to find out the final answer and display it using C language.
Here is the code
#include <stdio.h>
int main(void)
{
//To find the area of triangle with 3sides
int a, b, c;
float s,area;
printf("Enter the values of a, b and c \n");
scanf("%d %d %d", &a, &b, &c);
/* compute s */
s = (a + b + c) / 2;
area = sqrt(s * (s - a) * (s - b) * (s - c));
printf("Area of a triangle = %f \n", area);
return 0;
}