One dimensional arrays of integers problem

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 1
Reputation: MMac1218 is an unknown quantity at this point 
Solved Threads: 0
MMac1218 MMac1218 is offline Offline
Newbie Poster

One dimensional arrays of integers problem

 
0
  #1
Dec 1st, 2008
I cant get the output to display the average, high, and low. Any hints?


  1. /* Write a program that prompts the user for test
  2. scores (doubles). The user enters -1 to stop the
  3. entry. After all of the test scores have been
  4. entered, calculate the average, the highest and
  5. the lowest test score. Use the code below as a
  6. template. Make sure you respond appropriately
  7. when no test scores are entered. Use the
  8. following screen shots as a guide.
  9. */
  10.  
  11. #include <iostream>
  12. using namespace std;
  13. int main()
  14. {
  15. double scores[75];
  16. int counter = -1;
  17. do
  18. {
  19. counter++;
  20. cout << "Please enter a score (enter -1 to stop): ";
  21. cin >> scores[counter];
  22. } while (scores[counter] >= 0);
  23.  
  24. }

I am very new at C++, I dont know where or how to add the High, Low, and Average in?

Any help would be greatly appreciated.

Thanks,
Mac
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: One dimensional arrays of integers problem

 
0
  #2
Dec 1st, 2008
Look at your colleague's meteorological suffering:
http://www.daniweb.com/forums/thread160190.html
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,836
Reputation: ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all 
Solved Threads: 119
ithelp's Avatar
ithelp ithelp is offline Offline
Posting Virtuoso

Re: One dimensional arrays of integers problem

 
0
  #3
Dec 1st, 2008
You need to increment counter in while loop.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 83
Reputation: nmaillet is an unknown quantity at this point 
Solved Threads: 18
nmaillet nmaillet is offline Offline
Junior Poster in Training

Re: One dimensional arrays of integers problem

 
0
  #4
Dec 1st, 2008
After the do-while loop is done you can calculate everything. You have the size of the set of scores, counter , so all you need to do is declare an integer as an index to use in a for loop, as well as three double's for the high, low and average.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC