So I'm in the process of finishing this program where I need to find the average grades of student 1 and the average grades of student 2 but it's giving me the cumulative average of all their grades. How can I reset the accumulator? Or is there another way to separate this?
So by "accumulator" you do mean total and loopCount?
Rhetoric question: Why are they correct for the first student?
A: Because you do set them properly before you get the first testScore of the first student.
Followup question: Can you change their value before you get the first testScore of the second/Nth student?
(Hint: What do you do for the second student on lines 46-49?)
Semi-unrelated question. How many averages do you calculate for a student that has 42 testScores?
A: 42
Q: Why? You print only the last one of them on line 73. Perhaps a move of line 66 out and after the loop to line 72?
PS. C had a fixed scope syntax: first variable declarations and then the code. That made it easy for the compiler to reserve space from stack for a function call.
C++ did relax that. A variable declaration does not have to be at the start of a function. It can be close to where the variable is actually used. (The compilers are more complex now and can cope with that.)
You could declare (and initialize) a variable within a loop body, if you don't need it after the loop. Then its lifetime is only that one iteration.