Answer
$${x^2}\sin x + 2x\cos x - 2\sin x + C$$
Work Step by Step
$$\eqalign{
& \int {{x^2}\cos x} dx \cr
& {\text{substitute }}u = {x^2},{\text{ }}du = 2xdx \cr
& dv = \cos xdx,{\text{ }}v = \sin x \cr
& {\text{ integration by parts}}{\text{, we have}} \cr
& \int {{x^2}\cos x} dx = {x^2}\sin x - \int {\left( {\sin x} \right)\left( {2xdx} \right)} \cr
& \int {{x^2}\cos x} dx = {x^2}\sin x - 2\int {x\sin x} dx \cr
& {\text{substitute }}u = x,{\text{ }}du = dx \cr
& dv = \sin xdx,{\text{ }}v = - \cos x \cr
& {\text{applying integration by parts}}{\text{, we have}} \cr
& \int {{x^2}\cos x} dx = {x^2}\sin x - 2\left( { - x\cos x - \int {\left( { - \cos x} \right)dx} } \right) \cr
& \int {{x^2}\cos x} dx = {x^2}\sin x + 2x\cos x - 2\int {\cos xdx} \cr
& {\text{integrating}} \cr
& \int {{x^2}\cos x} dx = {x^2}\sin x + 2x\cos x - 2\sin x + C \cr} $$