How to solve this? I am having difficulty in the very last step of the problem. The general solution of $\vert\sin x\vert = \cos x$ is -
(A) $2n\pi+{\pi\over4}$, $n\in I$
(B) $2n\pi±{\pi\over4}$, $n\in I$
(C) $n\pi+{\pi\over4}$, $n\in I$
(D) None of these
So what I did was - I made a case for when sinx is greater than 0 and equated it to $\cos x$ to get $\tan x = 1$ which implies x = $\pi\over 4$. The other case was when $\cos x = -\sin x$. Here, x = $3\pi\over 4$. I don't understand how to proceed from here.

We will solve $\sin^{2}(x) = \cos^{2}(x)$, which is obtained upon squaring the equation (so we do not have to deal with sign issues).
$$\sin^{2}(x) = \cos^{2}(x)$$
$$\cos^{2}(x) -\sin^{2}(x) = 0$$
$$\cos(2x) = 0$$
$$x = \frac{\pi}{4} + \pi n, \frac{3\pi}{4} + \pi n$$
$$x = \frac{\pi}{4} + 2\pi n, \frac{5\pi}{4} + 2\pi n, \frac{3\pi}{4} + 2\pi n, \frac{7\pi}{4} + 2\pi n$$
Here, we split into cases of $2\pi n$ periodicity to take advantage of the properties of $\sin$ and $\cos$.
Checking these solutions in the original equation $\vert \sin(x)\vert = \cos (x)$, we find that only $\frac{\pi}{4} + 2\pi n$ and $\frac{7\pi}{4} + 2\pi n$ work. $\frac{7\pi}{4} + 2\pi n$ is equivalent to $-\frac{\pi}{4} + 2\pi n$, so the answer is $\boxed{(\text{B})\ \pm\frac{\pi}{4} + 2\pi n.}$
You can do a sanity check by drawing a quick graph and seeing if the functions intersect in the general region of the conjectured solution.
