You can get a total of the scores for calculating the class average when you read the file in the first loop.
Code:class_average = 0; for(index = 0; index < 10; index = index + 1) { in_file >> firstname[index]; in_file >> lastname[index]; in_file >> test_score[index]; class_average += test_score[index]; } // now calculate the average class_average /= 10;