Note that the d.e is of the form $M(x,y)\text{d}x+N(x,y) \text{d}y$ with
$$ M(x,y)=2xy^2+\cos (x),~N(x,y)=2x^2y+\sin (y) $$
and the equation is exact if and only if $\displaystyle\frac {\partial M}{\partial y}=\frac{\partial N}{\partial x}.$
Now lets check if the differential equation is indeed exact.
$\displaystyle\frac{\partial M}{\partial y}=\frac{\partial}{\partial y}\left(2xy^{2}+\cos x\right)=4xy=\frac{\partial}{\partial x}\left(2x^{2}y+\sin y\right)=\frac{dN}{\partial x}$.
So the equation is exact.
The general solution is of the form $f\left(x,y\right)=C$ and it's given by
$$
f\left(x,y\right)=\int M(x,y)\text{d}x =\int(2xy^{2}+\cos x)\text{d}x=x^{2}y^{2}+\sin(x)+ g(y).$$
To find $g\left(y\right)$ differentiate $f\left(x,y\right)$ partially
with respect to $'y'$ and compare with $N\left(x,y\right).$
That is:
$f_{y}\left(x,y\right)=\dfrac{\partial}{dy}\left(x^{2}y^{2}+\sin x+g(y)\right)=2x^{2}y+g'\left(y\right).$
Comparing with $N\left(x,y\right)$, we find $g'\left(y\right)=\sin y,$
which implies that $g\left(y\right)=-\cos y+K$.
Hence, the general solution is $ x^2y^2+\sin x-\cos y=C.\quad\quad\Box$
Added
What happens if $M(x,y)\text{d}x+N(x,y)\text{d}y=0$ is not exact? Then there exist a function $u(x,y)$ such that $$[u(x,y)M(x,y)]\text{d}x+[u(x,y)N(x,y)]\text{d}y=0$$ is exact. The function $u$ is called an integrating factor. Furthermore, If $$\frac{M_y-N_x}{N}$$ is a function of $x$ only, say, $v(x)$, then $u(x,y)=u(x)=e^{\int v(x)\text{d}x}$.
On the other hand if $$\frac{M_y-N_x}{-M}$$ is a function of $y$ only, say, $w(y)$, then $u(x,y)=u(y)=e^{\int w(y)\text{d}y}$.
As an example, consider $(3xy-y^2)\text{d}x+(x^2-xy)\text{d}y=0$. Clearly, this is not exact. But $\dfrac{M_y-N_x}{N}=\dfrac{1}{x}=v(x)$, a function of $x$ only. So our integrating factor becomes $$u(x)=e^{\int \frac{1}{x}\text{d}x}=e^{\ln |x|}=|x|.$$
Verify that $$(3x^2y-xy^2)\text{d}x+(x^3-x^2y)\text{d}y=0$$ is now exact!
We now proceed as before to find the general solution.
As Sean mentioned in the comments... The constants are entirely determined by the initial conditions of your equation. Given your equation we have;
$${x^3\over3}+C_1={y^2\over2}+C_2 \implies {x^3\over3}+C_3={y^2\over2}$$
$$y=\bigg({2x^3\over3}+C_4\bigg)^{1\over 2}$$
Where $C_3=C_1-C_2$ and $C_4=2C_3$.
Now lets say that we were given the initial condition $y(0)=1$. That would yield...
$$y(0)=(C_4)^{1\over2}=1 \implies C_4=2C_3=2(C_1-C_2)=1$$
$$\therefore C_1-C_2={1\over2}$$
So $\textbf{any}$ 2 constants ($C_1$ and $C_2$) which satisfy that condition will give a legitimate solution to your equation with the given initial condition.
Best Answer
We get $v'=x^{-2}(1+x)(1-x)e^{C}$ if we add a constant $C$. When you integrate this you get another constant but the DE is not satisfied unless the second constant is $0$. So the solution we get is simply $C_1$ times the solution we get without adding a constant where $C_1=e^{C}$. It is obvious that if $y$ is a solution to the DE so is any constant multiple of it. So there is a no point in adding the constant during the process of finding $y$. We can always introduce the constant factor at the end.