Solution:Let the number of boys in a class be a, and their average age is b years. Let the age of teacher is c years.
Sum of ages of all students in the class = 30 × 20 = 600 years
So, a × b + (30 - a) × (b + 3) = 600
So, a × b + 30b + 90 - a × b - 3a = 600
So, a = 10b - 170 ........ (1)
When teacher is also included
So, (a × b + c)/(a + 1) = b + 3
So, a × b + c = a × b + 3a + b + 3
So, c = 3a + b + 3 ........ (2)
Put value of b in equation 2 from equation 1
c = 3a + (a + 170)/10 + 3
c = 31a/10 + 20
But a, should be an integral value
Put a = 10
Then c = 31 × 10/10 + 20 = 51
Put a = 20
Then, c = 31 × 20/10 + 20 = 82 (not possible)
C is the age of teacher which is between 49 and 54 years.
So only possible value of a = 10