 # C Programming Code Examples

## C > Mathematics Code Examples

### Program to calculate Area of Equilatral triangle

``` Program to calculate Area of Equilatral triangle An equilateral triangle has equal sides(all three sides are equal). In order to calculate the area of equilateral triangle, we must know the side of the triangle. This program would prompt user to enter the side of the equilateral triangle and based on the value, it would calculate the area. Formula used in the program: Area = sqrt(3)/4 * side * side Here sqrt refers the "square root", this is a predefined function of "math.h" header file. In order to use this function, we have included the "math.h" header file in the program. #include<stdio.h> #include<math.h> int main() { int triangle_side; float triangle_area, temp_variable; //Ask user to input the length of the side printf("\nEnter the Side of the triangle:"); scanf("%d",&triangle_side); //Caluclate and display area of Equilateral Triangle temp_variable = sqrt(3) / 4 ; triangle_area = temp_variable * triangle_side * triangle_side ; printf("\nArea of Equilateral Triangle is: %f",triangle_area); return(0); } ``` 