Really easy C++ program.. im a nooob

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

  1. GTS4eva

    GTS4eva New Member

    Joined:
    Feb 20, 2005
    Messages:
    272
    Likes Received:
    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 Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    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. GTS4eva

    GTS4eva New Member

    Joined:
    Feb 20, 2005
    Messages:
    272
    Likes Received:
    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. Corp

    Corp OT Supporter

    Joined:
    Sep 11, 2003
    Messages:
    28,201
    Likes Received:
    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_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,183
    Likes Received:
    506
    First, make a flowchart. That'll help you a lot.

    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. :o
     
  6. Sexual Vanilla

    Sexual Vanilla New Member

    Joined:
    May 23, 2005
    Messages:
    6,305
    Likes Received:
    0
    Location:
    South Carolina
    I miss those easy assignments. :wtc:
     
  7. Doc Brown

    Doc Brown Don't make me make you my hobby

    Joined:
    Mar 31, 2006
    Messages:
    16,404
    Likes Received:
    0
    Location:
    Ohio
    To all you guys who responded to thread starter: You suck [​IMG]

    And to thread starter, I only said that because I have no f'ing idea what
    you people are talking about, I just wanted to post in a c++ thread. :mamoru: :hs:
     

Share This Page