text: Polygon with maximum sides that can be inscribed in an N | C ++ program for the above approach ; Function to find the maximum sided polygon that can be inscribed ; Base Case ; Return n / 2 if n is even Otherwise , return - 1 ; Driver Code ; Given N ; Function Call
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int MaximumSides ( int n ) { if ( n < 4 ) return -1 ; return n % 2 == 0 ? n / 2 : -1 ; } int main ( ) { int N = 8 ; cout << MaximumSides ( N ) ; return 0 ; }