Thursday, September 4, 2025
HomeData Modelling & AIProgram to find the Interior and Exterior Angle of a Regular Polygon

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

Given the number of sides n of a regular polygon. The task is to find out the Interior angle and Exterior angle of the polygon.
Examples
 

Input : n = 6
Output : Interior angle: 120
         Exterior angle: 60

Input : n = 10
Output: Interior angle: 144
        Exterior angle: 36

 

Interior angle: The angle between two adjacent sides inside the polygon is known as the Interior angle. 
Formula to find the Interior angle:
Interior Angle = \frac{(n-2)\times 180}{n}
Exterior angle: The angle formed by any side of a polygon and the extension of its adjacent side is known as Exterior angle.
Exterior angle = \frac{360}{n}
 

interior and exterior angle

Program to find interior and exterior angles of a Regular Polygon: 
 

C++




// CPP program to find the interior and
// exterior angle of a given polygon
#include <iostream>
using namespace std;
 
// function to find the interior and
// exterior angle
void findAngle(int n)
{
    int interiorAngle, exteriorAngle;
 
    // formula to find the interior angle
    interiorAngle = (n - 2) * 180 / n;
     
    // formula to find the exterior angle
    exteriorAngle = 360 / n;
 
    // Displaying the output
    cout << "Interior angle: " << interiorAngle << endl;
 
    cout << "Exterior angle: " << exteriorAngle;
}
 
// Driver code
int main()
{
    int n = 10;
     
    // Function calling
    findAngle(n);
    return 0;
}


Java




// Java program to find the interior and
// exterior angle of a given polygon
import java.io.*;
 
class GFG {
     
    // function to find the interior and
    // exterior angle
    static void findAngle(int n)
    {
        int interiorAngle, exteriorAngle;
     
        // formula to find the interior angle
        interiorAngle = (n - 2) * 180 / n;
         
        // formula to find the exterior angle
        exteriorAngle = 360 / n;
     
        // Displaying the output
        System.out.println("Interior angle: " + interiorAngle);
     
        System.out.println("Exterior angle: " + exteriorAngle);
    }
     
    // Driver code
    public static void main (String[] args)
    {
        int n = 10;
     
        // Function calling
        findAngle(n);
    }
}


Python3




# Python3 program to find
# the interior and exterior
# angle of a given polygon
 
# function to find
# the interior and
# exterior angle
def findAngle(n):
 
    # formula to find the
    # interior angle
    interiorAngle = int((n - 2) * 180 / n)
     
    # formula to find
    # the exterior angle
    exteriorAngle = int(360 / n)
 
    # Displaying the output
    print("Interior angle: " ,
            interiorAngle )
 
    print("Exterior angle: " ,
           exteriorAngle )
 
# Driver code
n = 10
     
# Function calling
findAngle(n)
 
# This code is contributed
# by Smitha


C#




// C# program to find the
// interior and exterior
// angle of a given polygon
using System;
 
class GFG
{
     
    // function to find
    // the interior and
    // exterior angle
    static void findAngle(int n)
    {
        int interiorAngle,
            exteriorAngle;
     
        // formula to find
        // the interior angle
        interiorAngle = (n - 2) * 180 / n;
         
        // formula to find
        // the exterior angle
        exteriorAngle = 360 / n;
     
        // Displaying the output
        Console.Write("Interior angle: " +
                    interiorAngle + "\n");
     
        Console.Write("Exterior angle: " +
                           exteriorAngle);
    }
     
    // Driver code
    public static void Main ()
    {
        int n = 10;
     
        // Function calling
        findAngle(n);
    }
}
 
// This code is contributed
// by Smitha


PHP




<?php
// PHP program to find the
// interior and exterior
// angle of a given polygon
 
// function to find the
// interior and exterior
// angle
function findAngle($n)
{
    $interiorAngle;
    $exteriorAngle;
 
    // formula to find
    // the interior angle
    $interiorAngle = ($n - 2) *
                      180 / $n;
     
    // formula to find
    // the exterior angle
    $exteriorAngle = 360 /$n;
 
    // Displaying the output
    echo "Interior angle: " ,
          $interiorAngle, "\n" ;
 
    echo "Exterior angle: " ,
          $exteriorAngle;
}
 
// Driver code
$n = 10;
 
// Function calling
findAngle($n);
 
// This code is contributed
// by inder_verma.
?>


Javascript




<script>
// JavaScript program to find the interior and
// exterior angle of a given polygon
 
// function to find the interior and
// exterior angle
function findAngle(n)
{
    let interiorAngle, exteriorAngle;
 
    // formula to find the interior angle
    interiorAngle = Math.floor((n - 2) * 180 / n);
     
    // formula to find the exterior angle
    exteriorAngle = Math.floor(360 / n);
 
    // Displaying the output
    document.write("Interior angle: " + interiorAngle + "<br>");
 
    document.write("Exterior angle: " + exteriorAngle);
}
 
// Driver code
    let n = 10;
     
    // Function calling
    findAngle(n);
 
// This code is contributed by Surbhi Tyagi.
</script>


Output

Interior angle: 144
Exterior angle: 36

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

Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

RELATED ARTICLES

1 COMMENT

  1. […] Approach: For any N sided regular polygon, when rotated by 360 degrees, it aligns in the original position of the polygon. To find the minimum angle of rotation we use the property of symmetry of regular polygons. For an N sided regular polygon when rotated by 360/N degrees, the rotated polygon is in the same position as of the original polygon, which is the exterior angle of an N-sided regular polygon. […]

Most Popular

Dominic
32260 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6747 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6695 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS