How to write C Program to find Area of an Equilateral Triangle, Perimeter, Semi Perimeter, and Altitude of an Equilateral Triangle of with example?.

Before we step into C Program to find Area of an Equilateral Triangle example, let see the definitions and formulas behind this.

## C Area of an Equilateral Triangle

The Equilateral Triangle is a triangle with all sides are equal, and all of the angles are equal to 60 degrees. If we know the side of an Equilateral Triangle, we can calculate the area of an Equilateral Triangle using the below formula.

Area = (√3)/4 * s² (S = Any side of the Equilateral Triangle)

Perimeter is the distance around the edges. We can calculate the perimeter of an Equilateral Triangle using below formula:

Perimeter = 3s

We can calculate Semi Perimeter of an Equilateral Triangle using the formula: 3s/2, or we can say Perimeter/2.

We can calculate Altitude of an Equilateral Triangle using the formula: (√3)/2 * s

### C Program to find Area of an Equilateral Triangle

This program allows the user to enter the length of any one side of an Equilateral Triangle. Using this value, we will calculate the Area, Perimeter, Semi Perimeter, Altitude of the Equilateral Triangle.

/* C Program to find Area of an Equilateral Triangle */ #include<stdio.h> #include<math.h> int main() { float side; float Area, Perimeter, Semi, Altitude; printf("\n Please Enter Length of any side\n"); scanf("%f",&side); Area = (sqrt(3)/4)*(side*side); Perimeter = 3*side; Semi = Perimeter/2; Altitude = (sqrt(3)/2)*side; printf("\n Area of Equilateral Triangle = %.2f\n",Area); printf("\n Perimeter of Equilateral Triangle = %.2f\n", Perimeter); printf("\n Semi Perimeter of Equilateral Triangle = %.2f\n", Semi); printf("\n Altitude of Equilateral Triangle = %.2f\n", Altitude); return 0; }

**OUTPUT:**

**ANALYSIS**

Within this C Program to find Area of an Equilateral Triangle, the Following statements will allow the user to enter the length of any side in the Equilateral Triangle.

printf("\n Please Enter Length of any side\n"); scanf("%f",&side);

Next, we are calculating the Area of an Equilateral Triangle using the Formula:

Area = (sqrt(3)/4)*(side*side);

sqrt() is the math function in C Programming, used to calculate the square root. It will return an error if we miss using the <math.h> header file.

In the next line of this C program, We are calculating the Perimeter of an Equilateral Triangle using the formula

Perimeter = 3*side;

In the next line, We are calculating the semi perimeter of an Equilateral Triangle using the following formula. We can also find semi perimeter using the standard formula = (3* side) / 2.

Semi = Perimeter/2

In the next line, We are calculating the Altitude of an Equilateral Triangle using the formula:

Altitude = (sqrt(3)/2)*side

The following printf statements will help us to print the Perimeter, Semi Perimeter, Altitude and Area of an Equilateral Triangle

printf("\n Area of Equilateral Triangle = %.2f\n",Area); printf("\n Perimeter of Equilateral Triangle = %.2f\n", Perimeter); printf("\n Semi Perimeter of Equilateral Triangle = %.2f\n", Semi); printf("\n Altitude of Equilateral Triangle = %.2f\n", Altitude);