printf will substitute an expression for the format specifier in the " " part of the printf line of code.
In this case, it will substitute sum/count for the %f. Obviously, sum is not staying zero the whole time, since 0/any number is nonsense.
To find an average, you need two things: 1) The sum of the quantities you're averaging, and 2) The number of items that you are putting into the sum.
If you play with that code a bit, you'll sort it out.