\[\text{Let total students} = N\]
\[\text{Marks of students: } x_1, x_2, x_3, \ldots, x_N\]
Incorrect data
\[
\textbf{Incorrect Average} = 30.8,\qquad x_1 = 24
\]
\[
30.8N = 24 + (x_2 + x_3 + \cdots + x_N)
\]
\[
x_2 + x_3 + \cdots + x_N = 30.8N - 24 \qquad (1)
\]
Correct data
\[
\textbf{Correct Average} = 31.4,\qquad x_1 = 42
\]
\[
31.4N = 42 + (x_2 + x_3 + \cdots + x_N)
\]
\[
x_2 + x_3 + \cdots + x_N = 31.4N - 42 \qquad (2)
\]
Equating
\[
30.8N - 24 = 31.4N - 42
\]
\[
31.4N - 30.8N = 42 - 24
\]
\[
0.6N = 18
\]
\[
N = \frac{18}{0.6} = 30
\]
\[
\boxed{N = 30}
\]