Write a C program to input side of an equilateral triangle from user and find area of the given equilateral triangle. How to find area of an equilateral triangle if sides of the triangle are given in C programming. C program to calculate area of an equilateral triangle if its side is given.

**Example**

**Input**

Enter side of the equilateral triangle: 10

**Output**

Area of equilateral triangle = 43.3 sq. units

## Required knowledge

Fundamentals of C, Data types, Talking user input in C

## Area of equilateral triangle

Area of equilateral triangle is given by the below formula.

## Logic to find area of equilateral triangle

The real logic of the program lies in converting the above mathematical formula in programming notation. For transforming the above mathematical formula to programming notation you must know two concepts.

The mathematical formula for area of equilateral triangle in programming notation can be written as (sqrt(3) / 4) * (side * side). Where sqrt() is a function used to compute square root. We will use this formula to find area of equilateral triangle.

Below is the step by step descriptive logic to find area of an equilateral triangle.

- Input side of the equilateral triangle in some variable say side.
- Apply the formula to find area i.e. area = (sqrt(3) / 4) * (side * side).
- Finally print the value of resultant area.

## Program to find area of an equilateral triangle

```
/**
* C program to find area of an equilateral triangle
*/
#include <stdio.h>
#include <math.h> //Used for sqrt() function
int main()
{
float side, area;
// Input side of equilateral triangle
printf("Enter side of an equilateral triangle: ");
scanf("%f", &side);
// Calculate area of equilateral triangle
area = (sqrt(3) / 4) * (side * side);
// Print the area
printf("Area of equilateral triangle = %.2f sq. units", area);
return 0;
}
```

**Note:** sqrt() function is used to calculate the square root of any number.

Output

Enter side of an equilateral triangle: 75 Area of equilateral triangle = 2435.69 sq. units

Happy coding 😉

### Recommended posts

- Basic programming exercises index.
- C program to find area of a triangle.
- C program to find angle of a triangle if its two angles are given.
- C program to check whether a triangle is valid or not if all its angles are given.
- C program to check whether a triangle is valid or not if all its sides are given.
- C program to check whether a triangle is Equilateral, Isosceles or Scalene triangle.
- C program to find area of rectangle.
- C program to find diameter, circumference and area of rectangle.

<pre><code> ----Your Source Code---- </code></pre>