text: Length of longest rod that can fit into a cuboid | C # program to find the longest rod that can fit in a cuboid ; Function to find the length ; temporary variable to hold the intermediate result ; length of longest rod is calculated using square root function ; Driver Code ; calling longestRodInCuboid ( ) function to get the length of longest rod
code: using System ; class GFG { static double longestRodInCuboid ( int length , int breadth , int height ) { double result ; int temp ; temp = length * length + breadth * breadth + height * height ; result = Math . Sqrt ( temp ) ; return result ; } public static void Main ( ) { int length = 12 , breadth = 9 , height = 8 ; Console . WriteLine ( ( int ) longestRodInCuboid ( length , breadth , height ) ) ; } }