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.
In reply to Re^3: Subroutine not correct (I think)
by Corion
in thread Subroutine not correct (I think)
by jcklasseter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |