Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "genlib.h"
- #include "simpio.h"
- #include <iostream>
- using namespace std;
- const int NumScores = 4;
- double GetScoresAndAverage(int numScores);
- int main()
- {
- cout << "This program averages" << NumScores << "scores." << endl;
- double average = GetScoresAndAverage(NumScores);
- cout << "The average is" << average << "." << endl;
- return 0;
- }
- double GetScoresAndAverage(int numScores)
- {
- int sum = 0;
- for (int i=0; i < numScores; i++){
- cout << "Next score?";
- int nextScore = GetInteger();
- sum += nextScore;
- }
- return double(sum)/numScores;
- }
Advertisement
Add Comment
Please, Sign In to add comment