Length of longest rod that can fit into 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
function longestRodInCuboid ( length , breadth , height ) { let result ; let temp ; temp = length * length + breadth * breadth + height * height ; result = Math . sqrt ( temp ) ; return result ; } let length = 12 , breadth = 9 , height = 8 ; document . write ( longestRodInCuboid ( length , breadth , height ) ) ;