Program to calculate area and perimeter of equilateral triangle

Tringle is a closed figure with three sides. An equilateral triangle has all sides equal. Area and perimeter of an equilateral triangle can be found using the below formula,

Area of equilateral triangle = (√3)/4*a2

Perimeter of equilateral triangle = 3 * a

Logic of Code

To find the area of an equilateral triangle program uses square-root and power functions. The math library has both these functions and can be used to do the calculation in the program.

The below code display program to calculate the area and perimeter of an equilateral triangle,


 Live Demo

#include <stdio.h>
#include <math.h>
int main(){
   int side = 5, perimeter;
   float area;
   perimeter = (3 * side);
   area = (sqrt(3)/4)*(side*side);
   printf("perimeter is %d
", perimeter);    printf("area is %f", area);    return 0; }


perimeter is 15
area is 10.825317

Updated on: 30-Jul-2019


Kickstart Your Career

Get certified by completing the course

Get Started