Obtaining a mean, while sentinel is 0

I'm writing a program where a user keeps entering numbers until "0" is entered.
Once "0" is entered the loop ends and It displays the mean. Problem is it counts the "0" in the average.


Enter number 1: 5
Enter number 2: 2
Enter number 3: 3
Enter number 4: 0

The mean is 2.5.

But I want it to only count everything before the "0".
(5 + 2 + 3) / 3 = 3.333333

reduce the count by 1 before calculating the average
abhishkem71 thank you. I can now properly find the mean.
Last edited on
I think if you just make max and min = price above the loop it should then keep track of min and max.
Topic archived. No new replies allowed.