C program to Find the Area of an Equilateral Triangle

In this C Programming example, we will implement the program to find the area of an equilateral triangle and print the output on the console.

1. What is an equilateral triangle and how to find its Area?

A Triangle with all angles at 60 degrees and congruent sides or an equiangular triangle is described as Equilateral Triangle.

In an equilateral triangle, median, angle bisector, and altitude for all sides are all the same.

The area of an equilateral triangle is √3 a2/ 4.

Equilateral Triangle
Example
Input:
side = 3

Output: 
The Area of Equilateral Triangle is: 3.892500

Helpful topics to understand this program better are-


2. C Program to find the area of an equilateral triangle

Let’s discuss the execution(kind of pseudocode) for the program to find the area of an equilateral triangle in C.

  1. Initially, we prompt the user to enter the side of the equilateral triangle.
  2. The value is stored in the int side and the value of the area of the triangle is stored in the float area.
  3. Now, the side length is used for the calculation in the formula area = ( 1.73 * side * side) / 4.
  4. After the calculations, the value is stored in the float area and use this variable to print the output.

Let us now implement the above execution of the program to find the area of an equilateral triangle in C.

#include <math.h>
#include <stdio.h>
int main() {
  int side;
  float area;
  printf("\nEnter the side of the triangle: ");
  scanf("%d", &side);

  area = (1.73 * side * side) / 4;

  printf("\nThe Area of an Equilateral Triangle is: %f", area);
  return (0);
}
Output

Enter the side of the triangle: 6
The Area of an Equilateral Triangle is: 15.570000

3. Conclusion

In this C Programming example, we have discussed how to find the area of an equilateral triangle in C.


Helpful Links

Please follow C Programming tutorials or the menu in the sidebar for the complete tutorial series.

Also for the example C programs please refer to C Programming Examples.

All examples are hosted on Github.


Recommended Books


An investment in knowledge always pays the best interest. I hope you like the tutorial. Do come back for more because learning paves way for a better understanding

Do not forget to share and Subscribe.

Happy coding!! ?

Recommended -

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Index