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