Given differential equation is $\frac{d y}{d x}+\frac{y}{x}=3 x$
It is a linear differential equation of the form
$\frac{d Y}{d x}+P y=Q$
$\therefore P=\frac{1}{x} \text { and } Q=3 x$
$\therefore IF =e^{\int P d x}=e^{\int \frac{1}{x} d x}$
$=e^{\log x}=x$
$\therefore $ Complete solution is
$y x=\int 3 x \times x d x +C$...(i)
$\Rightarrow y x=3\left[\frac{x^{3}}{3}\right]+C$
$\Rightarrow y=x^{2}+\frac{C}{x}$
Also, Eq. (i) can be written as
$y x=\int 3 x \times x dx-C$
$\Rightarrow y x=x^{3}-C$
$\Rightarrow y= x^{2}-\frac{C}{x}$