in reply to Re: Subroutine not correct (I think)
in thread Subroutine not correct (I think)

Unfortunately, that gave me the same output as before.

Replies are listed 'Best First'.
Re^3: Subroutine not correct (I think)
by Corion (Patriarch) on Jun 17, 2015 at 13:33 UTC

    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.