In this article we will show you, How to write C Program to find Area of an Equilateral Triangle, Perimeter, Semi Perimeter and Altitude of a Equilateral Triangle of with example. Before we step into practical example, Let see the definitions and formulas behind the Area of an Equilateral Triangle.

## 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 then, we can calculate the area of an Equilateral Triangle using below formula.

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

Perimeter is the distance around the edges. We can calculate perimeter using below formula:

Perimeter = 3s

We can calculate Semi Perimeter of an Equilateral Triangle using the formula: 3s/2 or we can simply 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 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.

**CODE**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
/* 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**

Following statements will allow the User to enter the length of any side in the Equilateral Triangle.

1 2 |
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:

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

sqrt() is the math function, which is used to calculate the square root.(It will return error if we miss to use the <math.h> header file.)

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

1 |
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.

1 |
Semi = Perimeter/2 |

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

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

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

1 2 3 4 |
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); |

Thank You for Visiting Our Blog

## Share your Feedback, or Code!!