You are setting sum to 0 each time the loop iterates. That is not what you should be doing. The sum should be initialized to 0 outside the loop, not within the loop.

Regards,

Paul McKenzie