Largest cube that can be inscribed within the sphere | C ++ Program to find the biggest cube inscribed within a sphere ; Function to find the side of the cube ; radius cannot be negative ; side of the cube ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; float largestCube ( float r ) { if ( r < 0 ) return -1 ; float a = ( 2 * r ) / sqrt ( 3 ) ; return a ; } int main ( ) { float r = 5 ; cout << largestCube ( r ) << endl ; return 0 ; }