Given an integer **N** representing N sided regular polygon, the task is to find the angle made by the sides on the centre of the polygon that is the central angle.

The

central angleis the angle formed by the two vertices forming an edge and the centre.

**Examples: **

Input:N = 6Output:60Explanation:

The polygon is a hexagon with an angle 60 degree.

Input:N = 5Output:72Explanation:

The polygon is a pentagon with an angle 72 degree.

**Approach: **The idea is to observe that since there is a regular polygon all the central angles formed will be equal.

All central angles would add up to 360 degrees (a full circle), so the measure of the central angle is 360 divided by the number of sides.

Hence,

central angle = 360 / N degrees, whereNis the number of sides.

Below is the implementation of the above approach:

## C++

`// C++ program for the above approach ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to calculate central ` `// angle of a polygon ` `double` `calculate_angle(` `double` `n) ` `{ ` ` ` `// Calculate the angle ` ` ` `double` `total_angle = 360; ` ` ` `return` `total_angle / n; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `double` `N = 5; ` ` ` `cout << calculate_angle(N); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program for the above approach ` `class` `GFG{ ` ` ` `// Function to calculate central ` `// angle of a polygon ` `static` `double` `calculate_angle(` `double` `n) ` `{ ` ` ` ` ` `// Calculate the angle ` ` ` `double` `total_angle = ` `360` `; ` ` ` `return` `total_angle / n; ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `double` `N = ` `5` `; ` ` ` ` ` `System.out.println(calculate_angle(N)); ` `} ` `} ` ` ` `// This code is contributed by rock_cool` |

*chevron_right*

*filter_none*

**Output:**

72

**Time Complexity:** O(1) **Auxiliary Space:** O(1)

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Nth angle of a Polygon whose initial angle and per angle increment is given
- Angle between 3 given vertices in a n-sided regular polygon
- Number of occurrences of a given angle formed using 3 vertices of a n-sided regular polygon
- Find the angle of Rotational Symmetry of an N-sided regular polygon
- Program to calculate angle on circumference subtended by the chord when the central angle subtended by the chord is given
- Program to find Area of Triangle inscribed in N-sided Regular Polygon
- Side of a regular n-sided polygon circumscribed in a circle
- Area of a n-sided regular polygon with given side length
- Area of a n-sided regular polygon with given Radius
- Length of Diagonal of a n-sided regular polygon
- Apothem of a n-sided regular polygon
- Area of largest Circle inscribe in N-sided Regular polygon
- Determine the position of the third person on regular N sided polygon
- Program to find the Interior and Exterior Angle of a Regular Polygon
- Find number of diagonals in n sided convex polygon
- Probability that the pieces of a broken stick form a n sided polygon
- Number of triangles formed by joining vertices of n-sided polygon with one side common
- Number of triangles formed by joining vertices of n-sided polygon with two common sides and no common sides
- Number of cycles formed by joining vertices of n sided polygon at the center
- Check if an N-sided Polygon is possible from N given angles

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.