Step 1: Spot the standard form:
The unknown here can be seen as a function of \(x\). So we rewrite the equation as a linear equation in \(y\).
Inverting the given equation gives the relation below.
\[ (1 + \sin x)\,\frac{dy}{dx} + y\cos x = -x \]
Step 2: Notice the product rule:
The left side is exactly the derivative of \((1+\sin x)\,y\).
\[ \frac{d}{dx}\big[(1+\sin x)\,y\big] = (1+\sin x)\frac{dy}{dx} + y\cos x \]
So the factor that makes the left side a perfect derivative is \(1 + \sin x\).
Step 3: Confirm with the formula:
Dividing by \(1+\sin x\) gives $P = \dfrac{\cos x}{1+\sin x}$.
Put $t = 1 + \sin x$, so that $dt = \cos x\,dx$. Then $\int P\,dx = \int \dfrac{dt}{t} = \log t$.
\[ e^{\int P\,dx} = e^{\log(1+\sin x)} = 1 + \sin x \]
Step 4: Test the other options:
At $x = 0$ the correct factor equals 1. Option (A) is $\log\cos 0 = 0$, which is not a valid factor.
Option (C) is $e^{1} \ne 1$ and its derivative does not match $P$ times itself.
Option (D) simplifies to $\cos x$. Its derivative is $-\sin x$, not $P\cos x$ divided by $1+\sin x$.
So only option (B) works.
Final Answer:
The integrating factor is option (B).
\[ \boxed{1 + \sin x} \]