For every continuous function $g$ does there exists a sequence of functions $\{f_n\}$ which converges to $g$? Let, 
$C(\Bbb R):=\\
\{f:\Bbb R \to \Bbb R| \text{ $f$ is continuous and $\exists$ a compact set $K$ such that $f(x)=0$, $\forall x\in K^c$}\}.$
Let, $\displaystyle g(x)=e^{-x^2}$ for all $x\in \Bbb R$. 
Then prove that there exists a sequence $\{f_n\}$ in $C(\Bbb R)$ such that $f_n \to g$ uniformly.
Here $g$ is continuous, so by Weierstress approximation theorem we can say that there always exists a sequence of polynomials $\{p_n(x)\}$ in $K$ which converges uniformly to $g$ in $K$. But in that case how can I define $f_n(x)$ in such a way that $f_n \in C(\Bbb R)$ ?

Let $f_n(x) = \begin{cases} g(x), & |x| \le n \\
g(n)(n+1-|x|), & n<|x| \le n+1 \\ 0, & \text{otherwise}
\end{cases}$ (I am using the fact that $g$ is even, but it is clear how this would work for any $g$ that satisfies $g(x) \to 0$ as $|x| \to\infty$.
Then $\|g-f_n\|_\infty \le \sup_{|x| \ge n} g(x) = g(n)$, hence the convergence is uniform since $\lim_{n \to \infty} g(x) = 0$.
