Official solution
Let x and y are number of boys and girls in a class respectively.
\[\therefore\] 52x + 42y = 50 (x + y)
\[ \Rightarrow\] 52x + 42y = 50x + 50y
\[ \Rightarrow\] 2x = 8y
\[ \Rightarrow\] x = 4y
\[\therefore\] Total no. of students = x + y = 4y + y = 5y
\[\therefore\] Percentage of boys = \[{{4y} \over {5y}} \times 100\,\% \] = 80\%