Nth angle of a Polygon whose initial angle and per angle increment is given | C ++ program for the above approach ; Function to check if the angle is possible or not ; Angular sum of a N - sided polygon ; Angular sum of N - sided given polygon ; Check if both sum are equal ; Function to find the nth angle ; Calculate nth angle ; Return the nth angle ; Driver Code ; Checks the possibility of the polygon exist or not ; Print nth angle of the polygon
#include <iostream> NEW_LINE using namespace std ; bool possible ( int N , int a , int b , int n ) { int sum_of_angle = 180 * ( N - 2 ) ; int Total_angle = ( N * ( ( 2 * a ) + ( N - 1 ) * b ) ) / 2 ; if ( sum_of_angle != Total_angle ) return false ; else return true ; } int nth_angle ( int N , int a , int b , int n ) { int nth = 0 ; nth = a + ( n - 1 ) * b ; return nth ; } int main ( ) { int N = 3 , a = 30 , b = 30 , n = 3 ; if ( possible ( N , a , b , n ) ) cout << nth_angle ( N , a , b , n ) ; else cout << " Not ▁ Possible " ; return 0 ; }