Area of a largest square fit in a right angle triangle | C ++ Program to find the area of the biggest square which can fit inside the right angled triangle ; Function to find the area of the biggest square ; the height or base or hypotenuse cannot be negative ; side of the square ; squaring to get the area ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; float squareArea ( float l , float b , float h ) { if ( l < 0 b < 0 h < 0 ) return -1 ; float a = ( l * b ) / ( l + b ) ; return a * a ; } int main ( ) { float l = 5 , b = 12 , h = 13 ; cout << squareArea ( l , b , h ) << endl ; return 0 ; }