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
function trianglearea ( r ) { if ( r < 0 ) return - 1 ; return r * r ; } var r = 5 ; document . write ( trianglearea ( r ) ) ;