5. A class has 45 people, of which 28 people participate in the mathematics interest group, and 21 people participate in the chemistry interest group. If the number of people who participate in both mathematics and chemistry is $x$, then the range of values for $x$ is ( ).
A. $17 \leqslant x \leqslant 24$
B. $4 \leqslant x \leqslant 21$
C. $x=4$
D. $x=8$
5. B. From $\left\{\begin{array}{l}21-x \geqslant 0 \\ 28-x \geqslant 0 \\ 49-x \leqslant 45,\end{array}\right.$ we get $4 \leqslant x \leqslant 21$.