Largest square that can be inscribed in a semicircle | Function to find the area of the square ; the radius cannot be negative ; area of the square ; Driver code
< ? php function squarearea ( $ r ) { if ( $ r < 0 ) return -1 ; $ a = 4 * ( pow ( $ r , 2 ) / 5 ) ; return $ a ; } $ r = 5 ; echo squarearea ( $ r ) ; ? >