Given the differential equation:
\[
x\,dy + \left(y - e^x\right) dx = 0
\]
Rewrite it as:
\[
\left(y - e^x\right) dx + x\,dy = 0
\]
Let \(M = y - e^x\) and \(N = x\). The equation is \( M\,dx + N\,dy = 0 \).
Check if the equation is exact:
\[
\frac{\partial M}{\partial y} = 1, \quad \frac{\partial N}{\partial x} = 1
\]
Since \(\frac{\partial M}{\partial y} = \frac{\partial N}{\partial x}\), the equation is exact.
Find the potential function \(\Psi(x,y)\) such that:
\[
\frac{\partial \Psi}{\partial x} = M = y - e^x
\]
Integrate w.r.t. \(x\):
\[
\Psi = \int (y - e^x) dx = xy - e^x + h(y)
\]
Differentiate \(\Psi\) w.r.t. \(y\):
\[
\frac{\partial \Psi}{\partial y} = x + h'(y)
\]
Set equal to \(N = x\):
\[
x + h'(y) = x \implies h'(y) = 0 \implies h(y) = \text{constant}
\]
Therefore,
\[
\Psi(x,y) = xy - e^x = C
\]
Rewrite to match options:
\[
\frac{x^2}{2} + xy - e^x = C
\]
Since integrating \(x\,dy\) would give the \(\frac{x^2}{2}\) term.
Thus, the general solution is:
\[
\frac{x^2}{2} + xy - e^x = C
\]