Program to calculate distance between two points in 3 D | Function for distance ; Driver code ; function call for distance
function distance ( x1 , y1 , z1 , x2 , y2 , z2 ) { var d = Math . pow ( ( Math . pow ( x2 - x1 , 2 ) + Math . pow ( y2 - y1 , 2 ) + Math . pow ( z2 - z1 , 2 ) * 1.0 ) , 0.5 ) ; document . write ( " " + d . toFixed ( 10 ) ) ; return ; } var x1 = 2 ; var y1 = - 5 ; var z1 = 7 ; var x2 = 3 ; var y2 = 4 ; var z2 = 5 ; distance ( x1 , y1 , z1 , x2 , y2 , z2 ) ;