how to print multiple iterations of a variable?

So i am making a program where the user enters a number of students from 1-20, and then it calculates the average grade of all those students. IT then prints every original score and the average

 ``1234567891011121314151617181920212223242526272829`` `````` #include using namespace std; int main() { double clas, score, sum = 0; cout << "Enter Class Size (1-20)" << endl; cin >> clas; if(clas >= 1 && clas <= 20) { for(double count = 1; count <= clas; count++) { cout << "Enter Score: " << endl; cin >> score; sum = sum + score; } double avg; avg = sum / clas; cout << endl; cout << "Original Scores: " << score << endl; cout << "Average: " << avg << endl; } else { cout << "Class is not within required range. The required range is 1-20." << endl; } return 0; }``````

i have this as my code. I don't know how to make it so that it prints every original score instead of just 1
The only way to print values is by having them. In other words, you have to store the values when you receive them.

You have probably already heard of arrays. While there are more dynamic solutions, a static array suites your problem. You know that you need to store (at most) 20 scores. Therefore, make an array for 20 scores.

Btw, why is clas a double? Would it not be rather morbid to have 3.14 students?
@keskiverto i just like to classify all my number variables as a double or float, i don't really like to use int unless i have no decimal points in my program hahaha

and also no we haven't had an assignment on arrays but i will look it up since i am teaching myself basically. Thank you!
Last edited on