Hi there,
I've writiten a program that asks a user to enter X number of users, it then asks the user to enter points and totals up the points. The cycle then runs again, dependent on the value of X.
However I would like to obtain an overall average of the x number of users total points. But I'm not really sure how to go about doing this?
Because the total points variable changes each time the loop starts again?
Any advice?
Many thanks
Matt seymour

10 Years
Discussion Span
Last Post by monkeyhead

Keep another variable outside the loop lets say grandTotal and at the end of each loop do something like grandTotal += loopTotal . Now this variable will hold the sum of all the totals. Don't forget to initialize grandTotal to 0.


Thanks for the advice! I manage to implent the idea into my work and it works!
Many thanks
Matt Seymour

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.