Answer
$y=\dfrac{-1+\sin x}{x}$
Work Step by Step
Here, we have $y'+(\dfrac{1}{x}) y=\dfrac{\cos x}{x}$
The integrating factor is: $I=e^{\int (\dfrac{1}{x}) dx}=x$
Now, $x[y'+(\dfrac{1}{x}) y]=x(\dfrac{\cos x}{x})$
This implies that
$\int [xy]' =\int \cos x dx $
$\implies (xy)=(\sin x)+c$
Now, apply the initial conditions.
Thus, we have $c=-1$
$xy=\sin x-1 \implies y=\dfrac{-1+\sin x}{x}$