loops

Okay I'm back. I am writing a program on averaging test scores of students. I am trying to use loops to input all of my data, however I am stuck on what that data will be stored as after all of the grades have been entered. For example, say I want to get the average grade of the entire class. If I have grade 1, 2, 3, and 4 entered by 4 different students, how would I input that into the program, as their would be 4 different grade 1's?


//06/30/2017
//Average Program
//program averages grades

#include <iostream>
#include <stdio.h>

using namespace std;

int main()

{
//student 1

int sID, grade1, grade2, grade3, grade4;

while (sID >= 0) {
cout << "Enter the students ID, press 0 if no more students " << endl;
cin >> sID;

cout << " Student ID is " << sID << endl;

cout << "1st test grade" << endl;
cin >> grade1;
cout << "2nd test grade" << endl;
cin >> grade2;
cout << "3rd test grade." << endl;
cin >> grade3;
cout << "4th test grade";
cin >> grade4;

}

cout "Average score for the class is " << (grade1 + grade2 + grade3)/4





system("pause");
return 0;
}
Topic archived. No new replies allowed.