Weierstrass approximation theorem says-
Set of all polynomials on a closed interval $[a,b]$ is dense in $C[a,b]$.
Using this result, we have to prove that Set of all polynomials on a closed and bounded set $X\subset\Bbb{R}$ is dense in $C(X,\Bbb{R}):=\{f:X\to\Bbb{R}:\ f\text{ is continuous and bounded}\}$.
We know that $X$ is closed and bounded hence it's compact.
Now if $X$ is union of finitely many closed and intervals, then we are done by Weierstrass approximation theorem.
What about the general case? Can anyone help me out? Thanks for help in advance.
As comment said it is enough to show that any continious function on $X$ can be extended to $\mathbb R$ and then use Weierstrass approximation theorem for some interval $[a,b]$ that contains $X$. The complement of $X$ is union of open intervals $(x_\alpha,y_\alpha)$(maybe some of $x_\alpha, y_\alpha$ is equal to $\pm \infty$). We can extend $f$ to each interval: just take linear function on it which takes appropriate values on its boundary.