![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
#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
Advertisements