/*************************************************/ // gradeAvg1.cpp // R. A. Hillyard // Last Modified: 09/10/2001 // // Determine the average of a set of scores // using a counter controlled loop /*************************************************/ #include <iostream> using namespace std; const int CLASS_SIZE = 5; //number of scores to be entered int main() { int gradeSum; //sum of all grades int counter; //number of grades entered int grade; //one grade //initialize loop variables counter = 0; //set loop count to 0 gradeSum = 0; //set total sum to 0 while(counter < CLASS_SIZE) { cout << "Enter grade " << counter+1 << ": "; cin >> grade; gradeSum += grade; counter++; }//end while gradeSum /= CLASS_SIZE; cout << "\nClass average is: " << gradeSum << endl; return 0; } /*********************Program Output***************/ Enter grade 1: 68 Enter grade 2: 93 Enter grade 3: 88 Enter grade 4: 65 Enter grade 5: 74 Class average is: 77