The given differential equation is in the linear form $\frac{dy}{dx} + P(x)y = Q(x)$.
Here, $P(x) = \sec x \csc x = \frac{1}{\cos x \sin x}$ and $Q(x) = \cos^2 x$.
Step 1: Find the integrating factor (I.F.).
I.F. $= e^{\int P(x) dx} = e^{\int \frac{1}{\sin x \cos x} dx}$.
To evaluate the integral, we can write $\int \frac{\sin^2 x + \cos^2 x}{\sin x \cos x} dx = \int (\frac{\sin x}{\cos x} + \frac{\cos x}{\sin x}) dx$.
$\int (\tan x + \cot x) dx = \log|\sec x| + \log|\sin x| = \log|\sec x \sin x| = \log|\tan x|$.
So, I.F. $= e^{\log|\tan x|} = |\tan x|$. We can choose the I.F. to be $\tan x$.
Step 2: Write the general solution.
The solution is given by $y \cdot (\text{I.F.}) = \int Q(x) \cdot (\text{I.F.}) dx + C$.
$y \tan x = \int \cos^2 x \cdot \tan x dx$.
$y \tan x = \int \cos^2 x \cdot \frac{\sin x}{\cos x} dx = \int \cos x \sin x dx$.
To integrate this, use the identity $\sin(2x) = 2\sin x \cos x$:
$y \tan x = \int \frac{\sin(2x)}{2} dx = \frac{1}{2} \int \sin(2x) dx$.
$y \tan x = \frac{1}{2} \left(-\frac{\cos(2x)}{2}\right) + C' = -\frac{\cos(2x)}{4} + C'$.
Using $\cos(2x) = 1-2\sin^2 x$:
$y \tan x = -\frac{1-2\sin^2 x}{4} + C' = -\frac{1}{4} + \frac{\sin^2 x}{2} + C' = \frac{\sin^2 x}{2} + C''$.
Multiply by 2:
$2y \tan x = \sin^2 x + 2C''$.
Let $c = 2C''$, so we have $2y \tan x = \sin^2 x + c$.