==========================================================
Explanation:
Average = (sum of scores)/(number of scores)
We can turn that equation into symbolic form to say
A = S/n
We're told that "18 students had an average of 80" (paraphrased) which means,
A = S/n
80 = S/18
80*18 = S
S = 1440
Those 18 students' scores add up to 1440.
For the other group of 40-18 = 22 students, their scores add to
S = A*n
S = 70*22
S = 1540
Overall, everyone's scores add up to 1440+1540 = 2980
Divide this over the number of people in class (40) to get the final answer
2980/40 = 74.5
--------------------------------------------
Here's an alternative way to compute the answer
(18/40)*80 + (22/40)*70 = 74.5
This works because 18/40 of the class got an average of 80 while the remaining 22/40 of the class got an average of 70.