C program to calculate the area of an equilateral triangle
ADVERTISEMENTS
C program to calculate the area of an equilateral triangle. There are you will learn how to find the area of an equilateral triangle in the C language.
Formula:
a = (sqrt(3) / 4) * (s * s)
Where:
a = area
s = side
Let us understand this example through the C program:
// C program to calculate the area of an equilateral triangle
#include <stdio.h>
#include <math.h>
// Used for sqrt() function
int main() {
float s, a;
// s = side
// a = area
printf("Enter the side of an equilateral triangle::\n");
scanf("%f", &s);
// Calculate area of equilateral triangle
a = (sqrt(3) / 4) * (s * s);
// Output
printf("\nArea of the equilateral triangle = %f sq. units", a);
return 0;
}
Output:
Enter the side of an equilateral triangle::
7
Area of the equilateral triangle = 21.217623 sq. units