$x \frac{d y}{d x}-y+x \sin \left(\frac{y}{x}\right)=0$
$x \frac{d y}{d x}-y+x \sin \left(\frac{y}{x}\right)=0$
$\Rightarrow x \frac{d y}{d x}=y-x \sin \left(\frac{y}{x}\right)$
$\Rightarrow \frac{d y}{d x}=\frac{y-x \sin \left(\frac{y}{x}\right)}{x}$ ...(1)
Let $F(x, y)=\frac{y-x \sin \left(\frac{y}{x}\right)}{x}$.
$\therefore F(\lambda x, \lambda y)=\frac{\lambda y-\lambda x \sin \left(\frac{\lambda y}{\lambda x}\right)}{\lambda x}=\frac{y-x \sin \left(\frac{y}{x}\right)}{x}=\lambda^{0} \cdot F(x, y)$
Therefore, the given differential equation is a homogeneous equation.
To solve it, we make the substitution as:
$y=v x$
$\Rightarrow \frac{d}{d x}(y)=\frac{d}{d x}(v x)$
$\Rightarrow \frac{d y}{d x}=v+x \frac{d v}{d x}$
Substituting the values of $y$ and $\frac{d y}{d x}$ in equation (1), we get:
$v+x \frac{d v}{d x}=\frac{v x-x \sin v}{x}$
$\Rightarrow v+x \frac{d v}{d x}=v-\sin v$
$\Rightarrow-\frac{d v}{\sin v}=\frac{d x}{x}$
$\Rightarrow \operatorname{cosec} v d v=-\frac{d x}{x}$
Integrating both sides, we get:
$\log |\operatorname{cosec} v-\cot v|=-\log x+\log \mathrm{C}=\log \frac{\mathrm{C}}{x}$
$\Rightarrow \operatorname{cosec}\left(\frac{y}{x}\right)-\cot \left(\frac{y}{x}\right)=\frac{\mathrm{C}}{x}$
$\Rightarrow \frac{1}{\sin \left(\frac{y}{x}\right)}-\frac{\cos \left(\frac{y}{x}\right)}{\sin \left(\frac{y}{x}\right)}=\frac{\mathrm{C}}{x}$
$\Rightarrow x\left[1-\cos \left(\frac{y}{x}\right)\right]=\mathrm{C} \sin \left(\frac{y}{x}\right)$
This is the required solution of the given differential equation.