# C program to find area of triangle given 3 sides devquora

Posted On: Dec 15, 2020 ### Overview:

Before starting this article, I would like to explain the term “area of Triangle”, which is defined as the region occupied inside the boundary of a flat Triangle. Then, I want to introduce you to the Geometric Shape triangle and I will explain What do you mean by area of a triangle and Heron’s Formula? Moreover, I will demonstrate how to find the area of a triangle? Furthermore, I will write a logic and c program to find the area of the triangle with output. After all, I will explain the resultant output.

### What is a Triangle?

A triangle is a three-sided polygon that consists of three edges and three vertices. If ABC is a triangle, then it is denoted as ∆ABC, where A, B and C are the vertices of the triangle and AB, BC, CA are the edges of the triangle. A triangle is a two-dimensional Geometric shape.

### What are the properties of the Triangle?

The properties of the triangle are as follows:

1. The sum of all the angles of a triangle(of all types) is equal to 180°.
2. The sum of the length of the two sides of a triangle is greater than the length of the third side.
3. In the same way, the difference between the two sides of a triangle is less than the length of the third side.
4. The side opposite the greater angle is the longest side of all the three sides of a triangle.
5. The exterior angle of a triangle is always equal to the sum of the interior opposite angles. This property of a triangle is called an exterior angle property.
6. Two triangles are said to be similar if their corresponding angles of both triangles are congruent and lengths of their sides are proportional.

### What do you mean by the area of a triangle?

The area of a triangle given 3 sides is the region enclosed by its perimeter or the three sides of the triangle. The standard unit for measurement of the area is meter2. In general area of the triangle is calculated as follows:

• The “Heron’s Formula” for the area of the triangle: √(s*(s-a)*(s-b)*(s-c));

### Where,

s is a semi parameter.

a, b and c are the edges of the triangle.

### Demonstration how to find area of a triangle: ### Define Heron’s Formula.

Heron’s formula includes two important steps as follows:

• Step 1: Find the semi perimeter of a triangle by adding all the three sides of a triangle and dividing it by 2.
• Step 2: apply the semi-perimeter of triangle value in the main formula called “Heron’s Formula” to find the area of a triangle.

The main formula called “Heron’s Formula” to find the area of a triangle is as follows:

√(s × (s-a) × (s-b) × (s-c));

The measurement unit of the area of a triangle is a square unit.

### Main Logic to find the area of a triangle

• Step 1: First of all declare 6 variables such as a, b,c for triangle sides, Perimeter P, semi perimeter s and Area.
• Step 1: User will enter the three sides of the triangle a, b, c.
• Step 2: Calculating the Perimeter of the Triangle using the formula P = a + b + c.
• Step 3: Calculating the semi perimeter using the formula (a + b + c)/2 and store it into variable s.
• Step 4: Calculating the Area of a triangle using Heron’s Formula: √(s × (s - a) × (s - b) × (s - c)); and store it into Area variable.
• Step 4: Print the variable area.

### C program to find area of triangle

```/* C Program to find Area of a Triangle and Perimeter of a Triangle */

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

int main()
{
float a, b, c, P, s, Area;

printf("\nPlease! Enter First edge of the triangle: ");
scanf("%f",&a);
printf("\nPlease! Enter Second edge of the triangle: ");
scanf("%f",&b);
printf("\nPlease! Enter Third edge of the triangle: ");
scanf("%f",&c);
P = a + b + c;
s = (a + b + c)/2;
Area = sqrt(s * (s - a) * (s - b) * (s - c));

printf("\n Perimeter of the Triangle = %.2f\n", Perimeter);
printf("\n Semi Perimeter of the Triangle = %.2f\n",s);
printf("\n Area of the triangle = %.2f\n",Area);

return 0;
}
```

The output of the Program: ### Conclusion

This Program accepts the three sides of the triangle a, b, c. Then, Calculates the Perimeter of the Triangle. Moreover, calculate the semi perimeter using the formula (a + b + c) / 2 and the Area of a triangle using Heron’s Formula: √(s × (s - a) × (s - b) × (s - c)). After the successful execution of the program the final area of a triangle is shown on screen.

Never Miss an Articles from us.

## Related Articles

#### C Program to convert Decimal to Binary Number

A Decimal Number is constructed with any digit from 0 to 9. For instance, 24 is a Decimal Number constructed from the digits 2 and 4. A Binary Number is constructed with digits 0 and 1. For instance, ..

#### C program to reverse a string

This program reversed the entered string that means opposite of the previous string sequence...

#### C program to reverse an Integer number

Are you want a demonstration of The C Program that reverses an Integer number? This Program reversing the sequence of digits in an Integer. After the successful compilation of the program, a message..