How to solve this indefinite integral?

Integrate by parts; by the product rule for derivatives, we have
[tex](u(x)v(x))'=u'(x)v(x)+u(x)v'(x)\implies u(x)v'(x)=(u(x)v(x))'-u'(x)v(x)[/tex]
[tex]\implies\displaystyle\int u(x)v'(x)\,\mathrm dx=u(x)v(x)-\int u'(x)v(x)\,\mathrm dx[/tex]
or more succinctly,
[tex]\displaystyle\int u\,\mathrm dv=uv-\int v\,\mathrm du[/tex]
Let
[tex]u=x\implies\mathrm du=\mathrm dx[/tex]
[tex]\mathrm dv=\cos x\,\mathrm dx\implies v=\sin x[/tex]
Then
[tex]\displaystyle\int x\cos x\,\mathrm dx=x\sin x-\int\sin x\,\mathrm dx[/tex]
so that
[tex]\displaystyle\int x\cos x\,\mathrm dx=\boxed{x\sin x+\cos x+C}[/tex]