Write a c program to find the area of an equilateral triangle


C program for area of equilateral triangle


Formula of area of equilateral triangle:
Area = (√3)/4 * a2

C code:

#include<stdio.h>
#include<math.h>

int main(){

    float a;
    float area;

    printf("Enter size of side of the equilateral triangle : ");
    scanf("%f",&a);

    area = sqrt(3)/4*(a*a);

    printf("Area of equilateral triangle is: %.3f",area);

    return 0;
}

Sample output:

Enter size of side of the equilateral triangle: 5
Area of equilateral triangle is: 10.825

Post a Comment