C Program to find area of Regular Polygon sides
Program
#include<stdio.h>
#include<math.h>
void main()
{
int num, side;
float denominator, numerator;
float tval, area;
printf("Enter the number of sides:\t");
scanf("%d", &num);
printf("Enter the length of sides:\t");
scanf("%d", &side);
numerator = pow(side, 2) * num;
tval = 180/num;
denominator = 4 * tan(tval);
area = numerator/denominator;
printf("Area of polygon: %f\n", area);
}
Output
Enter the number of sides: 4
Enter the length of sides: 3
Area of polygon: 5.556327