Program to find the Interior and Exterior Angle of a Regular Polygon in C++


In this problem, we are given a number n that denotes the sides of a regular polygon. Our task is to create a Program to find the Interior and Exterior Angle of a Regular Polygon in C++.

Problem Description − Here, for the given number of sides, we will find the value of each interior and exterior angle of the regular polygon of side n.

Interior Angle is the angle between two adjacent sides of a polygon that lies inside the polygon.

Exterior Angle is the angle between two adjacent sides of a polygon that lies outside the polygon.

Let’s take an example to understand the problem,

Input

n = 5

Output

Interior Angle = 108,
Exterior Angle = 72

Solution Approach

A simple solution to the problem is using the formula to find the interior angle of a regular polygon of side n.

The formula for Exterior Angle

( 360 )/n

The exterior angle of a polygon is the complement of the interior angle of the polygon.

The formula for Internal Angle

180 - (360 /n)

Program to illustrate the working of our solution,

Example

 Live Demo

#include <iostream>
using namespace std;
int FindExtAnglePolygon(int n) {
   return (360 / n);
}
int main() {
   int n = 10;
   cout<<"Interior Angle: "<<(180 - FindExtAnglePolygon(n));
   cout<<"\nExterior Angle: "<<FindExtAnglePolygon(n);
   return 0;
}

Output

Interior Angle: 144
Exterior Angle: 36

Updated on: 15-Sep-2020

223 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements