C Program to Find Area of Equilateral Triangle

In this article, we are going to discuss how to calculate the area of an equilateral triangle. So let’s start!

C Program to Find Area of Equilateral Triangle

For example –

Input :

So first to calculate the area of the equilateral triangle we are taking user input so for that we simply Enter the side of the equilateral triangle that is 24

Logic:

To calculate the area of the equilateral triangle we know the formula first so the formula is :

Equivalent to area = sqrt(3)/4 * a * a

To apply this formula in our program we simply use sqrt() function in it. Because in this formula we are going to deal with a square root that’s why we use sqrt() function in it. For that, we use <math.h> header file it.

Output:

According to our output, we simply get our output as-

Enter the side of the equilateral triangle: 24

The area of the equilateral triangle is 249.415314

// C program to calculate the area of the equilateral triangle

#include<stdio.h>
#include<math.h>

int main(){
float side. area ;
printf(“Enter the side of equilateral triangle :”);
scanf(“%f”, & side);
area = sqrt(3)/4 * side * side;
printf(“Area of equilateral triangle is %f”, area);
return 0;
}

Output

Enter the side of the equilateral triangle: 24

The area of an equilateral triangle is 249.415314

In this way, we simply understand how to calculate the area of an equilateral triangle. I hope this thing is clear to you. So for now keep learning and keep exploring.