VOOZH about

URL: https://www.geeksforgeeks.org/dsa/program-calculate-area-perimeter-equilateral-triangle/

⇱ Program to calculate area and perimeter of equilateral triangle - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Program to calculate area and perimeter of equilateral triangle

Last Updated : 17 Feb, 2023

An equilateral triangle is a triangle in which all three sides and angles are equal. All three internal angles of equilateral triangle measures 60 degree.

  • If we know the length of each sides of equilateral triangle, then we can use below mentioned formula to calculate area of equilateral triangle.
Area of Equilateral Triangle = (sqrt(3)/4) * a * a 
  • If we know the length of altitude of equilateral triangle along with the length of side, then we can use below mentioned formula to calculate it's area.
Area of Equilateral Triangle = (1/2) x Side x Altitude

Perimeter of Equilateral Triangle :

Perimeter of Equilateral Triangle : 3 X a

How does the area formula work?
Let us take a look at below diagram. We know are of a triangle is 1/2 * base * height. The value of h is sqrt(a2 – (a/2)2) = sqrt(3) * a / 2. So the area becomes 1/2 * a * (sqrt(3) * a / 2) = (sqrt(3)/4) * a * a

👁 Image
 

Examples:

Input : side = 4
Output : Area of Equilateral Triangle: 6.9282
 Perimeter of Equilateral Triangle: 12
Input : side = 12
Output : Area of Equilateral Triangle: 62.3538
 Perimeter of Equilateral Triangle: 36

Output
Area of Equilateral Triangle: 6.9282
Perimeter of Equilateral Triangle: 12

Time Complexity: O(1)

Auxiliary Space: O(1)

Comment