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
< ? php function longestRodInCuboid ( $ length , $ breadth , $ height ) { $ result ; $ temp ; $ temp = $ length * $ length + $ breadth * $ breadth + $ height * $ height ; $ result = sqrt ( $ temp ) ; return $ result ; } $ length = 12 ; $ breadth = 9 ; $ height = 8 ; echo longestRodInCuboid ( $ length , $ breadth , $ height ) ; ? >