The problem is that you're using %d to print a float instead of %f.
If you understand what you're doing, you're not learning anything.