VOOZH about

URL: https://www.geeksforgeeks.org/dsa/program-to-find-the-perimeter-of-a-regular-polygon/

⇱ Program to find the Perimeter of a Regular Polygon - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Program to find the Perimeter of a Regular Polygon

Last Updated : 21 Aug, 2022

Given the number of sides 'n' and the length of side 's' of a regular polygon, the task is to find out the Perimeter of this polygon.

Examples: 

Input: n = 7, s = 10
Output: Perimeter : 70
Since the sides are 7,
Hence the given polygon is Heptagon.
Therefore. Perimeter = 7*10 = 70

Input: n = 5, s = 2.5
Output: Perimeter : 12.5
Since the sides are 5,
Hence the given polygon is Pentagon.
Therefore. Perimeter = 5*2.5 = 12.5

Approach: In geometry, a regular polygon is a closed figure with all sides equal. It is a two-dimensional figure. 

Perimeter of a Regular Polygon = Number of sides * Length of each side

👁 Image


 

👁 Image


Below is the implementation of the above approach: 


Output: 
Perimeter of Regular Polygon 
with 5 sides of length 2.500000 = 12.500000

 


Time Complexity: O(1), since there is no loop or recursion.
Auxiliary Space: O(1), since no extra space has been taken.

Comment
Article Tags: