Program to find the Radius of the incircle of the triangle | C ++ Program to find the radius of the incircle of the given triangle ; Function to find the radius of the incircle ; the sides cannot be negative ; semi - perimeter of the circle ; area of the triangle ; Radius of the incircle ; Return the radius ; Driver code ; Get the sides of the triangle ; Find the radius of the incircle
#include <bits/stdc++.h> NEW_LINE using namespace std ; float findRadiusOfIncircle ( float a , float b , float c ) { if ( a < 0 b < 0 c < 0 ) return -1 ; float p = ( a + b + c ) / 2 ; float area = sqrt ( p * ( p - a ) * ( p - b ) * ( p - c ) ) ; float radius = area / p ; return radius ; } int main ( ) { float a = 2 , b = 2 , c = 3 ; cout << findRadiusOfIncircle ( a , b , c ) << endl ; return 0 ; }