in reply to Subroutine not correct (I think)

In line 34 you have already computed the differences. Just square the values:
return sqrt($x**2 + $y**2 + $z**2);

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^2: Subroutine not correct (I think)
by jcklasseter (Sexton) on Jun 17, 2015 at 13:28 UTC
    Unfortunately, that gave me the same output as before.

      What steps have you taken to inspect the return value of your distance() function?

      Also consider re-reading sprintf and printf and the replies you already got. Many of them addressed two problems in your program, but changing the formula is only one problem.