Guest User

Untitled

a guest
Mar 24th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include "genlib.h"
  2. #include "simpio.h"
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. const int NumScores = 4;
  7.  
  8. double GetScoresAndAverage(int numScores);
  9.  
  10. int main()
  11. {
  12.     cout << "This program averages" << NumScores << "scores." << endl;
  13.     double average = GetScoresAndAverage(NumScores);
  14.     cout << "The average is" << average << "." << endl;
  15.     return 0;
  16. }
  17.  
  18. double GetScoresAndAverage(int numScores)
  19. {
  20.     int sum = 0;
  21.     for (int i=0; i < numScores; i++){
  22.         cout << "Next score?";
  23.         int nextScore = GetInteger();
  24.         sum += nextScore;
  25.     }
  26.     return double(sum)/numScores;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment