Let the common ratio between number of boys and girls be x
Number of boys = 7x
Number of girls = 5x
As per the question,
Number of boys = Number of girls + 8
7x = 5x + 8
Transpose 5x to LHS, we will get
7x - 5x = 8
2x = 8
Divide both sides by 2
x = 4
No. of boys = 7x = 7 × 4 = 28
No. of girls = 5x = 5 × 4 = 20
Total class students = 28 + 20 = 48