 # C Program to find the area of a triangle with three sides

For a better understanding of this c program example, we always recommend you to learn the basic topics of C programming listed below:

## How to find the area of a triangle

Here we are explaining how to write a C program to find a triangle area with three sides. Triangles can be classified into different types by following shapes and properties. Important among them are the Equilateral triangle, Isosceles triangle, Right-angled Triangle. In this case, we use a normal Triangle for finding its Area. 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 the main, we are doing the whole program.

In this, we use the following equation to find the area of the Triangle.

Area = sqrt[s(s-a)*(s-b)*(s-c)],where s = (a+b+c)/2 where a,b,c are the three sides of the triangle.

## How area calculation of triangle implemented in C Program

We are defining each variable using the `int` datatype and taking the user's input to get the Triangle's sides' values. Given below are the steps which are used in the C program to find the area. In this C program, we accept the user's values using the `scanf` and `printf `method and compute the value of 'S', which is used in the main Formula to find the triangle area. Finally, apply the main formula and print the result.

## ALGORITHM

STEP 1: Include the header files used in C programming to use some built-in functions inside the program such as `stdio.h`, `conio.h`, `math.h`

STEP 2: Open the main() to start the program, C program execution starts with the main()

STEP 3: Accept the Sides of the Triangle from the user using `printf` and `scanf` built-in functions and store the values in Variables.

STEP 4: Calculate the value of S using the formula a+b+c /2

STEP 5: Calculate the area using the formula we mentioned in the description.

STEP 6: Using the `printf` method print the value of the area in C programming.

## C Source Code

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

void main() {
int s, a, b, c, area; // defines the variables.
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

```Enter the values of a,b and c

3
4
5
Area of a triangle = 6
```
VIEW ALL
VIEW ALL
##### OtherTutorials
VIEW ALL 