# Program to calculate area and perimeter of equilateral triangle

CServer Side ProgrammingProgramming

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,

## Example

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\n", perimeter);
printf("area is %f", area);
return 0;
}

## Output

perimeter is 15
area is 10.825317
Published on 09-Jul-2019 07:00:56