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.
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
#include < stdio.h > #include < math.h > int main() { float sides, area, p; printf("Enter value for side of Equilateral Triangle\n"); scanf("%f", &sides); p = 3 * sides; area = ( (sqrt(3)/4) * pow(sides, 2) ); printf("Perimeter is %f\n", p); printf("Area is %f\n", area); return 0; }
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