Click Here to see the problem detail.
Solution
Here,
Angle by n segments is: 2∏ radian = 360 degree
Angle by one segment is, θ= 2∏/n radian = 360/n degree
from the above figure we get,
h/r=sinθ
=>h=r*sinθ
Area of the triangle =Area by one segment= (1/2)*r*h=0.5*r*r*sinθ
Area by n segments =n*0.5*r*r*sinθ
Source Code
#include<stdio.h> #include<math.h> int main() { double n,r,areaOne,areaAll,theta; while(scanf("%lf%lf",&r,&n)==2) { theta=2*acos(-1); theta=theta/n; areaOne=0.5*r*r*sin(theta); areaAll=areaOne*n; printf("%.3lf\n",areaAll); } return 0; }