Largest cube that can be inscribed within a right circular cone | Function to find the side of the cube ; height and radius cannot be negative ; side of the cube ; Driver code
< ? php function cubeSide ( $ h , $ r ) { if ( $ h < 0 && $ r < 0 ) return -1 ; $ a = ( $ h * $ r * sqrt ( 2 ) ) / ( $ h + sqrt ( 2 ) * $ r ) ; return $ a ; } $ h = 5 ; $ r = 6 ; echo cubeSide ( $ h , $ r ) ; ? >