Please Compute this in C Write a program that will compute t


Please Compute this in C.
Write a program that will compute the area of User selected regular polygons. If the User inputs T The User shall then be asked the length of one side in meters. The Console Window shall display the area of a equilateral triangle If the User inputs S The User shall then be asked the length of one side in meters. The Console Window shall display the area of a square If the User inputs P The User shall then be asked the length of one side in meters. The Console Window shall display the area of a regular pentagon If the User inputs H The User shall then be asked the length of one side in meters. The Console Window shall display the area of a regular hexagon If the User inputs anything else The Console Window shall display an error message You must adjust the specifiers in your code so that you arrive at the same results displayed in the following Console Window Scenarios: AREA CALCULATOR FOR REGULAR POLYGONS Enter:

Solution

#include <stdio.h>
#include <math.h>
int main()
{
float side = 0 ;
float area = 0 ;
char choice;
scanf(\"%c\",&choice);
printf(\"%c\",choice);
switch (choice) {
case \'T\': printf(\"Enter the length of a side in meters : \");
scanf(\"%f\",&side);
area = sqrt(3)/4*side*side;
printf(\"Area of Triangle is: %f\",area);
break;
case \'S\': printf(\"Enter the length of a side in meters : \");
scanf(\"%f\",&side);
area = side*side;
printf(\"Area of Square is: %f\",area);
break;
case \'P\': printf(\"Enter the length of a side in meters : \");
scanf(\"%f\",&side);
area = sqrt(5*(5+2*sqrt(5)))/4*side*side;
printf(\"Area of Pentagon is: %f\",area);
break;
case \'H\': printf(\"Enter the length of a side in meters : \");
scanf(\"%f\",&side);
area = 3*sqrt(3)/2*side*side;
printf(\"Area of Hexagon is: %f\",area);
break;
default:
printf(\"Invalid Choice , You may enter T or S or P or H only\");
}
}

 Please Compute this in C. Write a program that will compute the area of User selected regular polygons. If the User inputs T The User shall then be asked the l

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site