C program to find the area of a triangle with three sides




Here we are explaining how to write a C program to find area of a given triangle with three sides given. We are defining each variable using int and take the users input to get the values for the sides of the triangle. finally We are using the formula to find area of triangle to get the output of the c program to find area of a triangle.


                In this c program we are using stdio, conio, and math header files to include some standard libraries into the program. after that main function starts inside main we are doing the whole program

1. Defines the variables s, a, b, c.

2. Accept the user input for getting the sides of the triangle.

3. Now apply our formula to calculate the area of triangle and display the result.

===================================================================
#include <stdio.h>
 
#include <conio.h>
 
#include <math.h>
 
void main()
{
	int s, a, b, c, area; // defines the variables.
 
	clrscr();
 
	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 = %d\n", area);
}
 
==================================================================
OUTPUT of C program to find a triangle area
==================================================================
Enter the values of a,b and c
3
4
5
Area of a triangale = 6