Tuesday, May 21, 2019

Program to calculate Area

Write a C program to find area of equilateral triangle

Formula used in the program: 
Area = sqrt(3)/4 * side * side

program:

#include<stdio.h>
#include<math.h>
int main()
{
   int triangle_side;
   float triangle_area, temp_variable;
   printf("\nEnter the Side of the triangle:");
   scanf("%d",&triangle_side);

   temp_variable = sqrt(3) / 4 ;
   triangle_area = temp_variable * triangle_side * triangle_side ;
   printf("\nArea of Equilateral Triangle is: %f",triangle_area);
   return(0);
}

Output:-


Enter the Side of the triangle
2
Area of Equilateral Triangle is: 1.732051

0 Comments:

Post a Comment