Program to find Area of Triangle inscribed in N | C ++ Program to find the area of a triangle inscribed in N - sided regular polygon ; Function to find the area of the polygon ; area of a regular polygon with N sides and side length len ; Function to find the area of a triangle ; area of one triangle in an N - sided regular polygon ; area of inscribed triangle ; Driver code
#include <bits/stdc++.h> NEW_LINE #include <cmath> NEW_LINE using namespace std ; double area_of_regular_polygon ( double n , double len ) { double P = ( len * n ) ; double A = len / ( 2 * tan ( ( 180 / n ) * 3.14159 / 180 ) ) ; double area = ( P * A ) / 2 ; return area ; } double area_of_triangle_inscribed ( double n , double len ) { double area = area_of_regular_polygon ( n , len ) ; double triangle = area / n ; double ins_tri = ( triangle * 3 ) ; return ins_tri ; } int main ( ) { double n = 6 , len = 10 ; cout << area_of_triangle_inscribed ( n , len ) << endl ; return 0 ; }