$(a)$ We know that $1$ molecule of $O_2$ contains $2$ oxygen atoms.
$1 \, mole$ of $O_2 = 32 \, g$.
$32 \, g$ of $O_2 = 1 \, mole = 6.022 \times 10^{23}$ oxygen molecules.
$16 \, g$ of $O_2 = \frac{1 \, mole}{32 \, g} \times 16 \, g = 0.5 \, mole$.
Number of $O_2$ molecules in $0.5 \, mole = 0.5 \times 6.022 \times 10^{23} = 3.011 \times 10^{23}$ molecules.
Since $1$ molecule of $O_2$ contains $2$ atoms,the number of oxygen atoms $= 3.011 \times 10^{23} \times 2 = 6.022 \times 10^{23}$ atoms.
$(b)$ $1 \, mole$ of carbon atoms contains $6.022 \times 10^{23}$ atoms.
Therefore,$0.1 \, mole$ of carbon atoms contains $= 0.1 \times 6.022 \times 10^{23} = 6.022 \times 10^{22}$ atoms.