C program for area of equilateral triangle

C program for area of equilateral triangle


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
 


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

 

No comments:

Post a Comment