Step 1: Setting up the integral.
We are tasked with finding the value of the integral:
\[
\int_0^\pi x \sin x \, dx
\]
Step 2: Integration by parts.
We use the method of integration by parts, which is given by the formula:
\[
\int u \, dv = uv - \int v \, du
\]
Let \( u = x \) and \( dv = \sin x \, dx \). Then, \( du = dx \) and \( v = -\cos x \). Applying the integration by parts formula:
\[
\int_0^\pi x \sin x \, dx = \left[ -x \cos x \right]_0^\pi + \int_0^\pi \cos x \, dx
\]
Evaluating the boundary terms:
\[
\left[ -x \cos x \right]_0^\pi = -( \pi \cos \pi - 0 \cos 0 ) = \pi
\]
Now integrating \( \int_0^\pi \cos x \, dx \):
\[
\int_0^\pi \cos x \, dx = \left[ \sin x \right]_0^\pi = \sin \pi - \sin 0 = 0
\]
Step 3: Conclusion.
Thus, the value of the integral is:
\[
\pi + 0 = 2
\]