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.

Input side of the equilateral triangle: 10

Output area: 43.3 sq. units.

Happy coding ;)

**Example:**Input side of the equilateral triangle: 10

Output area: 43.3 sq. units.

### Required knowledge

Fundamentals of C, Data types, Talking user input in C#### Area of equilateral triangle

Area of equilateral triangle can be given by below formula:### Program

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

Output

Enter side of an equilateral triangle: 75

Area of equilateral triangle = 2435.69 sq. units.

Area of equilateral triangle = 2435.69 sq. units.

**Note:**sqrt() function is used to calculate the square root of any number. Read more about how to find square root of any number.

Happy coding ;)

### You may also like

- 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.
- C program to convert length from centimeter to meter and kilometer.
- C program to convert temperature from Fahrenheit to Celsius.
- C program to convert days to years, weeks and days.

Thanks for nice post.know details

ReplyDelete