I'm confused -- why are there two sets of code?
Anyway:
1) In the first set of code, you never initialize 'perfect_score'. Remember that variables don't automatically start at zero, you need to initialize them to have them start at zero.
2) In both sets of code you are creating an array (SCORES / values) with a non-const variable size, which is not legal in standard C++:
|
int SCORES[num_students]; // this only works if 'num_students' is const, which it isn't
|
3) This isn't an error... but what's the point of 'score' in the second set of code? It's always zero... you never change it. And you only use it here:
perfect += score + 1;
... which is the same as incrementing 'perfect' by 1 since 'score' is always zero.
#1 might throw a warning, and #2 should throw an error, but a lot of compilers will let you get away with #2 without complaining even though it technically isn't legal. I'm guessing your compiler doesn't complain, and your teacher's compiler does, which is why it won't compile for him.
Note you don't even need an array for this. Just combine those two for loops into one for loop. Like... just get the score, then see if the score is 100 right away. No need to record all the scores and check them all later.