To find the derivative of \( x\sin x \) we will need to use the product rule. Furthermore, we will also need to recall the derivatives of $x$ and $\sin x$. Specifically,
$$\dfrac d{dx} x = 1$$
and
$$\dfrac d{dx}\sin x = \cos x$$
If you would like a refresher on how to find the derivative of $\sin x$, you can find it here. Now recall the product rule
$$\dfrac d{dx} (f(x)g(x)) = f'(x)g(x) + f(x) g(x)$$
In this case, we will let $f(x) = x$ and $g(x) = \sin x$. Then
$$f(x) = 1$$
and
$$g'(x) = \cos x$$
Substituting these values into the product rule formula, we will get
$$ \boxed{\sin x + x \cos x}$$
As an aside, note that a very common mistake is to differentiate each term in the product independently to get
$$1\cdot\cos x = \cos x$$
which is a very common mistake and should be avoided. Remember that when you differentiate a product of two functions, you must always use the product rule. Now that we know how to differentiate $x\sin x$, let us attempt the same process with $x\cos x$. Indeed
$$\dfrac d{dx} x\cos x$$
can be found by following the same process. We will let $f(x) = x$ and $g(x) = \cos x$ and follow the same steps:
$$f'(x) = 1$$
$$g'(x) = -\sin x$$
We will now combine the above with the product rule to get the derivative of the product
$$f'(x)g(x) + f(x)g'(x) = \cos x \,-\, x\sin x$$
This result is very similar to the one in the original problem, which is expected.