/*************************************************/ // gradeAvg1_for.cpp // R. A. Hillyard // Last Modified: 02/16/2001 // // Determine the average of a set of scores // using a for 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 so far int grade; //one grade gradeSum = 0; //set total sum to 0 for(counter = 1; counter <= CLASS_SIZE; counter++) { cout << "Enter grade " << counter << ": "; cin >> grade; gradeSum += grade; }//end while cout << "\nClass average is: " << gradeSum/CLASS_SIZE << endl; return 0; } /*********************Program Output*************** Enter grade 1: 77 Enter grade 2: 87 Enter grade 3: 97 Enter grade 4: 79 Enter grade 5: 78 Class average is: 83 */