Differential equation dy/dx = x When taking the integral of $\frac{x}{y}$, we have:
$ydy = xdx$
$y^2 = x^2 + c$
$y = \sqrt{x^2 +c}$
We are able to move y to the other side and then integrate.
However, in the simple case of the integral of $x$, this fails.
$dy = xdx$
$dy/x = dx$
$\frac{y}{x} = x+c$
$y = x^2 +xc$
Obviously, there is a problem The integral of x is $\frac{x^2}{2}$.

*

*xc doesn't mean anything.


*there is no constant c for  $xc =-\frac{1}{2}x^2$
Why makes this fail?
 A: Some remarks:

*

*In the "first problem" you should write \begin{align*}\frac{dy}{dx}&=\frac{x}{y},\\ydy&=xdx,\\ \int ydy&=\int xdx,\quad (\star)\\ \frac{y^{2}}{2}+c_{1}&=\frac{x^{2}}{2}+c_{2},\quad c_{1},c_{2}\in \mathbf{R},\\
y^{2}&=\frac{2x^{2}}{2}+\underbrace{2(c_{2}-c_{1})}_{=c},\\
y&=\pm \sqrt{x^{2}+c}\end{align*}

*In the "second problem", you can consider the ODE as a separable equation
\begin{align*}
\frac{dy}{dx}&=x,\\ dy&=xdx,\\ \int dy &=\int xdx, \quad (\star)\\ y+c_{1}&=\frac{x^{2}}{2}+c_{2},\quad c_{1},c_{2}\in {\bf R}\\ y&=\frac{x^{2}}{2}+\underbrace{c_{2}-c_{1}}_{=c},\\ \color{blue}{y}&\color{blue}{=\frac{x^{2}}{2}+c}
\end{align*}

*Or you can consider the ODE as a exact equation (this is what you are really trying to do):
$$-xdx+dy=0$$
Define $P(x,y):=-x$ and $Q(x,y):=1$, then $P_{y}=Q_{x}$ so the ODE is a exact equation. Then there exists a function $f(x,y)$ (the solution for the ODE will be $f(x,y)=c$ for some constant $c$) such that $$\frac{\partial f}{\partial x}=P(x,y)\quad \text{and}\quad \frac{\partial f}{\partial y}=Q(x,y).$$
This is the step you are misunderstanding, and that is that the integration here is a "partial integration", this means that the constant will depend on the variable that is not involved in the integration, i.e.
$$\frac{\partial f}{\partial x}=P(x,y)$$ $$f(x,y)=\int -xdx=-\frac{x^{2}}{2}+\color{blue}{\varphi(y)},\quad (\star) $$where $\varphi(y)$ is an arbitrary function of $y$ and we can find it function because we know that $\frac{\partial f}{\partial y}=Q(x,y)$ then $$\frac{\partial f(x,y)}{\partial y}=\frac{\partial}{\partial y}\left(-\frac{x^{2}}{2}+\varphi(y)\right)=\frac{d\varphi}{dy},$$
then $\frac{d\varphi}{dy}=Q(x,y):=1$ give $\boxed{\varphi(y)=y}$
Therefore, $f(x,y)=-\frac{x^{2}}{2}+y$ and the general solution can be written as $$-\frac{x^{2}}{2}+y=c$$
or equivalent $$\color{blue}{y=\frac{x^{2}}{2}+c}$$

Notice we arrived to the same family of solutions. This is one of the reasons why it is always recommended to study whether the differential equation is separable, because as you can see, formulating it as an exact differential equation becomes "problematic". The problem in your approach is that when you use indefinite integrals you always have to keep in mind to add the respective integration constants. Moreover, strictly speaking all integrables $(\star)$ should be definite integrals.
