There is a 1D Array for names and a 2D Array for scores. How would you display the name of the student who received the highest total score? Below I have a segment of my source code.
1 2 3 4 5 6 7 8 9 10 11
void calcHighestScore(){
int highest = 0;
for(int i=0; i<NUM_OF_STUDENTS; i++){
int total = 0;
for(int j=0; j<NUM_OF_SCORES; j++){
total+=studentScores[i][j];
}
if(total>highest)
highest=total;
}
}
I know this calculates the highest score but how would you go about displaying the name related to that score. Any help is appreciated.
You need to get the index of the highest score and this index you can use to get the name of the student.
Do you have to use separate arrays?
Would be easier if you could use structs.
We have to use separate arrays. So the index you say, but the array is a 2D Array so I would have to take the sum of the individual scores. But wouldn't that just be a variable not an array so how would I use that index?