Largest right circular cone that can be inscribed within a sphere | Function to find the radius of the cone ; radius 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 coner ( R ) { if ( R < 0 ) return - 1 ; var r = ( 2 * Math . sqrt ( 2 ) * R ) / 3 ; return r ; } function coneh ( R ) { if ( R < 0 ) return - 1 ; var h = ( 4 * R ) / 3 ; return h ; } var R = 10 ; document . write ( " " + coner ( R ) . toFixed ( 5 ) + " " + " " + coneh ( R ) . toFixed ( 5 ) ) ;