text: Area of a n | C ++ Program to find the area of a regular polygon with given side length ; Function to find the area of a regular polygon ; Side and side length cannot be negative ; Area degree converted to radians ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; float polyarea ( float n , float a ) { if ( a < 0 && n < 0 ) return -1 ; float A = ( a * a * n ) / ( 4 * tan ( ( 180 / n ) * 3.14159 / 180 ) ) ; return A ; } int main ( ) { float a = 9 , n = 6 ; cout << polyarea ( n , a ) << endl ; return 0 ; }