Calculate area and height of an isosceles triangle whose sides are radii of a circle | C ++ program for the above approach ; Function to convert given angle from degree to radian ; Function to calculate height and area of the triangle OAB ; Stores the angle OAB and OBA ; Stores the angle in radians ; Stores the height ; Print height of the triangle ; Stores the base of triangle OAB ; Stores the area of the triangle ; Print the area of triangle OAB ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; double Convert ( double degree ) { double pi = 3.14159265359 ; return ( degree * ( pi / 180 ) ) ; } void areaAndHeightOfTraingle ( double radius , double a ) { if ( a >= 180 a == 0 ) { cout << " Not ▁ possible " ; return ; } double base_angle = ( 180 - a ) / 2 ; double radians = Convert ( base_angle ) ; double height = sin ( radians ) * radius ; cout << " Height ▁ of ▁ triangle ▁ " << height << endl ; double base = cos ( radians ) * radius ; double area = base * height ; cout << " Area ▁ of ▁ triangle ▁ " << area << endl ; } int main ( ) { double R = 5 , angle = 120 ; areaAndHeightOfTraingle ( R , angle ) ; return 0 ; }