Here is a rule which almost always works: (You can differentiate the solution to check). Integrate $M$ with respect to $x$ keeping $y$ as a constant and integrate only those terms of $N$ which do not involve $x$ with respect to $y$. Sum the result and equate to a constant.
So as $\displaystyle\int_{y\mbox{ constant}}Mdx=\int(5x+4y)dx=\frac{5x^2}{2}+4xy$, and $\displaystyle\int\mbox{(Terms of $N$ free of $x$) } dy=-8\int y^3dy=-2y^4$ we have $\frac{5x^2}{2}+4xy-2y^4=c$ as the solution.
$ydx+xdy=0 \tag 1$
$M=y$ and $N=x$ and $\frac{\partial M}{\partial y}=\frac{\partial
N}{\partial x}=1$, so Eq.$(1)$ is exact.
$\frac{y}{x}dx+dy=0 \tag 2$
$M=\frac{y}{x}$ and $N=1.$ Therefore $\frac{\partial M}{\partial
y}=\frac{1}{x}$ and $\frac{\partial N}{\partial x}=0$, so Eq.$(2)$ is not exact.
To make exact Eq.$(2)$, one have to multiply it by an integrating factor which is $x$ in this case :
$x\left(\frac{y}{x}dx+dy=0\right)=ydx+xdy=0$
Now, the equation is exact.
Of course, $(1)$ and $(2)$ are related to a same equation $(3)$ :
$\frac{dy}{dx}=-\frac{y}{x} \tag 3$
But don't confuse $(1)$ , $(2)$ and $(3)$. They are not identical equations. They are related by multiplying them by factors. It is normal that one of them is an exact differential and the others not exact differential.
The purpose of the game is to find a convenient factor called "integrating factor" such as a given non exact ODE becomes a different ODE which is then an exact ODE.
SECOND EXAMPLE :
$(y^2\arctan(y)+y^2x+\arctan(y)+x)dx+(x+y)dy=0 \tag 4$
The integrating factor is $\frac{1}{1+y^2}$.
If one multiply Eq.$(4)$ by $\frac{1}{1+y^2}$ he obtains after simplification :
$(x+\arctan(y))dx+\frac{x+y}{1+y^2}dy=0 \tag 5$
which is exact.
Best Answer
A note on terminology: The theorem you refer to as Gauss's theorem is more commonly called Green's theorem. Gauss's theorem often refers to the divergence theorem (which is a generalazation of green's theorem, and thus both may be reffered to as Gauss's theorem).
Now, let us state Green's theorem (by wikipedia):
Note that the theorem requires the curve to be closed. Thus, you may not apply the theorem for curves that have different end points.