C Program To Find Area Of An Equilateral Triangle - CodingBroz
Maybe your like
In this post, we will learn how to find the area of an equilateral triangle using the C Programming language.
A triangle having all the sides equal and each angle equal to 60 degrees is called an equilateral triangle.
The formula to calculate the area of an equilateral triangle is: Area of Equilateral Triangle = (√3/4) * (side)2.
We will use this formula in our program to find the area of an equilateral triangle.
So, without further ado, let’s begin this tutorial.
Table of Contents- C Program to Find Area of an Equilateral Triangle
- How Does This Program Work?
- Conclusion
- Related
C Program to Find Area of an Equilateral Triangle
// C Program to Find Area of an Equilateral Triangle #include <stdio.h> #include <math.h> int main(){ float side, area; // Asking for input printf("Enter the side of an equilateral triangle: "); scanf("%f", &side); // Calculating area of equilateral triangle area = (sqrt(3) / 4) * (side * side); // Display result printf("Area of the triangle = %.2f", area); return 0; }Output
Enter the side of an equilateral triangle: 9 Area of the triangle = 35.07How Does This Program Work?
float side, area;In this program, we have declared two floating data type variables named side and area.
// Asking for input printf("Enter the side of an equilateral triangle: "); scanf("%f", &side);Then, the user is asked to enter the side of the equilateral triangle. This gets stored in the side named variable.
// Calculating area of equilateral triangle area = (sqrt(3) / 4) * (side * side);We calculate the area of the equilateral triangle using the formula: area = (√3/4) * (side)2. Here, the sqrt() function is used to find the square root of a number. It is defined in the math.h header file.
// Display result printf("Area of the triangle = %.2f", area);Finally, the area of the equilateral triangle is displayed on the screen using the printf() function. We have used %.2f format specifier to limit the area to 2 decimal places.
Conclusion
I hope after going through this post, you understand how to find the area of an equilateral triangle using the C Programming language.
If you have any doubt regarding the program, then contact us in the comment section. We will be delighted to assist you.
Also Read:
- C Program to Find Area of Trapezium
- C Program To Calculate Area of Square
- C Program to Find Area of Parallelogram
- C Program To Calculate Area of Rectangle
- C Program to Find Area of Right Angled Triangle
Related
Tag » Area Of Equilateral Triangle C Program
-
C Program To Find Area Of An Equilateral Triangle - Codeforwin
-
C Program To Find Area Of An Equilateral Triangle - Tutorial Gateway
-
C Program To Calculate Area Of An Equilateral Triangle
-
Program To Find The Area Of An Equilateral Triangle - Javatpoint
-
C Program To Find Area Of Equilateral Triangle - Codingeek
-
C Program To Calculate Area Of Equilatral Triangle
-
C Program To Calculate The Area Of An Equilateral Triangle
-
C Program Area Of Equilateral Triangle - Java Tutoring
-
Find Area Of An Equilateral Triangle: C Program
-
C Program To Find Area Of An Equilateral Triangle - Tuts Make
-
C Program To Check Whether The Triangle Is Equilateral, Isosceles Or ...
-
C++ Exercises: Calculate Area Of An Equilateral Triangle - W3resource
-
C Program To Find Area Of Equilateral Triangle - Oodlescoop
-
C Program To Find Area Of Equilateral Triangle