Largest cone that can be inscribed within a cube | C ++ Program to find the biggest cone 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; float coneRadius ( float a ) { if ( a < 0 ) return -1 ; float r = a / sqrt ( 2 ) ; return r ; } float coneHeight ( float a ) { if ( a < 0 ) return -1 ; float h = a ; return h ; } int main ( ) { float a = 6 ; cout << " r ▁ = ▁ " << coneRadius ( a ) << " , ▁ " << " h ▁ = ▁ " << coneHeight ( a ) << endl ; return 0 ; }