Area of a largest square fit in a right angle 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
< ? php function squareArea ( $ l , $ b , $ h ) { if ( $ l < 0 $ b < 0 $ h < 0 ) return -1 ; $ a = ( $ l * $ b ) / ( $ l + $ b ) ; return $ a * $ a ; } $ l = 5 ; $ b = 12 ; $ h = 13 ; echo round ( squareArea ( $ l , $ b , $ h ) , 4 ) ; ? >