Largest right circular cylinder that can be inscribed within a cone | C # Program to find the biggest right circular cylinder that can be fit within a right circular cone ; Function to find the biggest right circular cylinder ; radius and height cannot be negative ; radius of right circular cylinder ; height of right circular cylinder ; volume of right circular cylinder ; Driver code
using System ; class GFG { static double cyl ( double r , double h ) { if ( r < 0 && h < 0 ) return - 1 ; double R = ( 2 * r ) / 3 ; double H = ( 2 * h ) / 3 ; double V = 3.14 * Math . Pow ( R , 2 ) * H ; return V ; } static public void Main ( ) { double r = 4 , h = 8 ; Console . WriteLine ( cyl ( r , h ) ) ; } }