This question already has an answer here:
The constant of integration only seems to be used at the very end of integration by parts despite the use of integrals beforehand.
An example of this would be: $$\int x\sin(x)\ dx = x\int sin(x)\ dx - \int x'(\int sin(x)\ dx)\ dx$$ Ordinarily, the right side of the equation would be simplified to: $$x(-cos(x)) - \int-cos(x)\ dx$$ And further to: $$-x(cos(x)) + sin(x)$$ Then finally arranged and given the constant of integration: $$sin(x) - xcos(x)+ C$$
What I am confused about is why $C$ is only added at the very end of this instead of at each integral.
I would be more inclined to use try something more like this: $$x(-cos(x) +C_1) - \int -cos (x) + C_2\ dx$$ Which would simplify to: $$-x(cos(x) -C_1) - \int-cos(x)\ dx + \int C_2\ dx $$ And further to: $$-xcos(x) +C_1x +sin(x)+ C_3 + C_2x + C_4 $$ Which finally arranges itself as: $$sin(x) - xcos(x) + C_5x + C_6$$ Where $C_5=C_1 + C_2$ and $C_6=C_3 + C_4$
I also feel I should probably mention I am a bit of an oblivious idiot so if the answer is completely obvious or my math is full of errors, I apologize.