$\displaystyle y'=x^2y+y cos x$
$\displaystyle \begin{aligned}\frac{dy}{dx}&=x^2y+y\cos(x)=y(x^2+ \cos(x))\\
&\implies\frac{dy}{y}=\bigg[x^2+\cos(x)\bigg]dx\\
&\implies\int\frac{dy}{y}=\ln|y|=\int\bigg[x^2+\cos(x)\bigg]dx=\frac{x^3}{3}+\sin(x)+C\\
&\implies{y=\pm{C_1e^{\frac{x^3}{3}+\sin(x)}}}
\end{aligned}$