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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.