I have parallel arrays called scores and names, with their shared size in SIZE. I need to print each student whose score is above the average, but my output includes an extra name.
My code calculates the sum inside a loop over the names, then checks whether average is at least 100 before printing. What am I missing?
frosting-by-committee:
So the second loop checks each score against the same average, rather than recalculating it for each name?
recheck-the-hatch:
Exactly. Sum all the scores first, divide by SIZE, then use that result for every comparison.