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