(a) Magnetic field at $P$ is $\overrightarrow{B}$, perpendicular to $OP$ in the direction shown in figure
So, $\overrightarrow{B} = B\sin{\theta\widehat{i}} - B\cos\theta\widehat{j}$
Here $B = \frac{\mu_{0}}{2\pi}\frac{I}{r}$
$\sin\theta = \frac{y}{r}$ and $\cos\theta = \frac{x}{r}$
$\therefore\overrightarrow{B} = \frac{\mu_{0}I}{2\pi}.\frac{1}{r^{2}}\left( y\widehat{i} - x\widehat{j} \right) = \frac{\mu_{0}I(y\widehat{i} - x\widehat{j})}{2\pi(x^{2} + y^{2})}\ \lbrack as\ r^{2} = x^{2} + y^{2}\rbrack$