Program to find the Circumcircle of any regular polygon in C++


In this problem, we are given two numbers that give the number of sides of a polygon N and the length of each side A. Our task is to create a Program to find the Circumcircle of any regular polygon in C++.

Problem description − Here, we need to find the radius and area of the circumcircle of the regular polygon whose side number and length are given.

Let’s take an example to understand the problem,

Input

n = 4 a = 2

Program to illustrate the working of our solution,

Example

 Live Demo

#include <bits/stdc++.h>
using namespace std;
void CalcRadAreaCircumcircle(float n, float a) {
   float r = a / sqrt( 2 * ( 1 - cos(360 / n)));
   cout<<"The radius of Circumcircle is "<<r<<endl;
   cout<<"The area of circumcircle is "<<((3.14)*r*r);
}
int main() {
   float n = 5, a = 6;
   CalcRadAreaCircumcircle(n, a);
   return 0;
}

Output

The radius of Circumcircle is 3.02487
The area of circumcircle is 28.7305

Updated on: 16-May-2022

141 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements