Largest cone that can be inscribed within a cube | Function to find the radius of the cone ; side cannot be negative ; radius of the cone ; Function to find the height of the cone ; side cannot be negative ; height of the cone ; Driver code
function coneRadius ( a ) { if ( a < 0 ) return - 1 ; var r = ( a / Math . sqrt ( 2 ) ) ; return r ; } function coneHeight ( a ) { if ( a < 0 ) return - 1 ; var h = a ; return h ; } var a = 6 ; document . write ( " " + coneRadius ( a ) . toFixed ( 5 ) + " " + " " + coneHeight ( a ) ) ;