While going through 'Plane Trigonometry by SL Loney' I came across an article for general value of $\cos x$ which is $\left(2n\pm\frac12\right)\cdot\frac\pi2$. But, when I am solving $\cos x = 0$, the answer I am getting is $\left(2n\pm\frac12\right)\cdot\frac\pi2$, but as per book the answer is $\left(n+\frac12\right)\cdot\frac\pi2$. Why does the answer only contain the plus sign but not the minus sign?
Both of your answers are correct, and are different representations of each other.
We can easily show that $\frac12\left(2m\pm\frac12\right)=\frac12\left(n+\frac12\right)$ for integer $m,n$. For any $m$, if $n=2m$, $\frac12\left(2m+\frac12\right)=\frac12\left(n+\frac12\right)$ (note the + sign) and if $n=2m-1$ then $\frac12\left(2m-\frac12\right)=\frac12\left(n+\frac12\right)$.