$$\frac{dy}{dx} = y\sin x-2\sin x, \quad y(0) = 0.$$
Initial Value Problem
Hint says: Find an integrating factor
$$\frac{dy}{dx} = y\sin x-2\sin x, \quad y(0) = 0.$$
Initial Value Problem
Hint says: Find an integrating factor
When we have a linear differential equation $y'+P(x)y=Q(x)$ of order 1 then $\mu (x)=e^{\int P(x) dx}$will be an integrating factor. In your case, it is $\mu(x)=e^{\cos(x)}$. Now multiply it both sides of the equation and you see $$d(e^{\cos(x)}y)=-2\sin(x)e^{\cos(x)}$$ The rest is easy.
If a differential equation has the form
$$ y'(x)+p(x)y(x)=q(x)\,, \quad (1), $$ then the integrating factor is given by
$$ m(x)= {\rm e}^{\int p(x) dx}\,. $$
You need to write your ode in the form of $(1)$ and then find the integrating factor. Then just multiply the original equation by the interating factor and integrate
$$ (m(x)y)'= q(x) \Rightarrow \frac{d}{dx}(e^{\cos(x)}y)=-2\sin(x)e^{\cos(x)} $$
$$ \Rightarrow e^{\cos(x)}y(x)=2\int e^{\cos(x)}(-\sin(x))dx + C = 2e^{\cos(x)} +C $$
$$ y(x)= 2 + C \,{\rm e}^{-\cos(x)} \,.$$
To find $C$, you need to use the initial condition $y(0)=0$,
$$ y(0) = 0 = 2 + C{\rm e}^{-\cos(0)} \Rightarrow C = -2 {\rm e}$$
Substituting the value of $C$ in the solution gives
$$ y(x)= 2 - 2 \,{\rm e}^{1-\cos(x)} \,.$$
The simplest type of this ODE is that separable rather than linear. So it is not necessary to treat it as a linear ODE to solve.
$\dfrac{dy}{dx}=y\sin x-2\sin x$
$\dfrac{dy}{dx}=(y-2)\sin x$
$\dfrac{dy}{y-2}=\sin x~dx$
$\int\dfrac{dy}{y-2}=\int\sin x~dx$
$\ln(y-2)=-\cos x+c$
$y-2=Ce^{-\cos x}$
$y=Ce^{-\cos x}+2$
$y(0)=0$ :
$Ce^{-1}+2=0$
$C=-2e$
$\therefore y=-2ee^{-\cos x}+2=2-2e^{1-\cos x}$
Hint: Write it as $\frac{y'}{y-2}=\sin(x)$ and integrate.