Find Area of an Equilateral Triangle: C Program


Given the sides of the Triangle, write a C program to calculate Perimeter and Area of a equilateral Triangle.

Related Read:
Find Area of a Triangle Using Its Sides: C Program

Note:
Equilateral Triangle: A Triangle is called equilateral triangle if length of 3 sides of it are equal.
Example: a = 10, b = 10, c = 10;

So we ask the user to input value of the side only once.

Formula To Calculate Perimeter and Area of Equilateral Triangle

Perimeter = a + a + a;
i.e., Perimeter = 3 * a;

Area = ( ( sqrt(3) / 4 ) * pow(a, 2));

where a is the value of side of the Equilateral Triangle.

Find Area of an Equilateral Triangle: C Program



YouTube Link: https://www.youtube.com/watch?v=ftjjhBLrLk4 [Watch the Video In Full Screen.]


Find Area of an Equilateral Triangle: C Program

  1. #include < stdio.h >  
  2. #include < math.h >  
  3.   
  4. int main()  
  5. {  
  6.     float sides, area, p;  
  7.   
  8.     printf("Enter value for side of Equilateral Triangle\n");  
  9.     scanf("%f", &sides);  
  10.   
  11.     p    = 3 * sides;  
  12.     area = ( (sqrt(3)/4) * pow(sides, 2) );  
  13.   
  14.     printf("Perimeter is %f\n", p);  
  15.     printf("Area is %f\n", area);  
  16.   
  17.     return 0;  
  18. }  

Output:
Enter value for side of Equilateral Triangle
75
Perimeter is 225.000000
Area is 2435.696533

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

Leave a Reply

Your email address will not be published. Required fields are marked *