# Really easy C++ program.. im a nooob

Discussion in 'OT Technology' started by GTS4eva, Jan 30, 2007.

1. ### GTS4evaNew Member

Joined:
Feb 20, 2005
Messages:
272
0
Location:
California
Hey,

I'm looking to find the minimum, maximum, and arithmetic mean (average) of numbers entered by a user. The use is first prompted to how many numbers will be entered then to enter them. Now WITHOUT storing the numbers, I need to display the minimum, maximum and the average of all the numbers once its entered. I'm not asking for a full on code, just something I may be overlooking? I am a complete beginner and I can't figure out how to even start with this.

Thanks

2. ### Penguin ManProtect Your Digital Liberties

Joined:
Apr 27, 2002
Messages:
21,691
0
Location:
Edmonton, AB
Think about how you can figure out those three things (min, max, mean) by storing only one value for each of them. The solution comes pretty naturally from that.

3. ### GTS4evaNew Member

Joined:
Feb 20, 2005
Messages:
272
0
Location:
California
You mean storing one value and adding them on as I go? Because if I do that I can find the mean no problem but then the maximum and maximum... do I have to make a check for each number entered?

4. ### CorpOT Supporter

Joined:
Sep 11, 2003
Messages:
28,200
0
Location:
Providence, RI
yes, have three int values, for the min and max check each number against the current min and max to see if that number is the new min or max. for the avg keep adding them and then divide by how many numbers are entered

5. ### Joe_CoolModerator

Joined:
Jun 30, 2003
Messages:
315,219
6,778

And you don't have to store all the numbers to do this, by the way. You store the minimum, the maximum, the count, and the sum.

If a number entered is less than the minimum, it becomes the new minimum. If it's more than the maximum, it becomes the new maximum. You add it to the sum and divide by the count, and you have the mean.

I've probably helped you too much already, so that's all you get.

6. ### Sexual VanillaNew Member

Joined:
May 23, 2005
Messages:
6,305
0
Location:
South Carolina
I miss those easy assignments.

Joined:
Mar 31, 2006
Messages:
16,403