// This program averages test scores. It asks the user for the // number of students and the number of test scores per student. #include using namespace std; int main() { int numStudents, // Number of students numTests, // Number of test per student total; // Accumulator for total scores double average; // Average test score // Get the number of students. cout << "This program averages test scores.\n"; cout << "For how many students do you have scores? "; cin >> numStudents; // Get the number of test scores per student. cout << "How many test scores does each student have? "; cin >> numTests; // Determine each student's average score. for (int student = 1; student <= numStudents; student++) { total = 0; // Initialize the accumulator. for (int test = 1; test <= numTests; test++) { int score; cout << "Enter score " << test << " for "; cout << "student " << student << ": "; cin >> score; total += score; } average = total / numTests; cout << "The average score for student " << student; cout << " is " << average << ".\n\n"; } return 0; }