Let the number of rows be x and number of students in a row be y.
Total students of the class = Number of rows × number of students in a row
= xy
Using the information given in the question,
Condition 1
Total number of students = (x-1)(y+3)
⇒ xy = (x-1) (y+3)
⇒ xy = xy - y + 3x - 3
⇒ 3x - y = 3 (i)
Condition 2
Total number of students = (x+2) (y-3)
xy = xy + 2y - 3x - 6
3x - 2y = -6 (ii)
Subtracting equation (ii) from (i)
(3x - y) - (3x - 2y) = 3-(-6)
⇒-y + 2y = 3 + 6
⇒y = 9
By using equation (i), we obtain
3x - 9 = 3
⇒3x - 9 + 3 = 12
⇒ x = 4
Number of rows = x = 4
Number of students in a row = y = 9
Number of total students in a class = xy = 4 × 9 = 36