= Solution
If $X$ is compact and $f:X\to\mathbb R$ is continuous, then $f(X)$ is compact by the <continuous image of a compact space> theorem. Every compact subset of $\mathbb R$ is bounded, so $f$ is bounded.
Conversely, suppose the metric space $X$ is not compact. For metric spaces, compactness is equivalent to <sequentially compact space>[sequential compactness], so there is a sequence of distinct points $(x_n)$ having no convergent subsequence. The set
$$
A=\{x_n:n\geq1\}
$$
is closed: an accumulation point would supply a convergent subsequence. It is also discrete for the same reason. Consequently the function
$$
g:A\to\mathbb R,
\qquad g(x_n)=n,
$$
is continuous. By part (a), $X$ is normal, and the <Tietze extension theorem> extends $g$ to a continuous $G:X\to\mathbb R$. Since $G(x_n)=n$, this extension is unbounded. Therefore, if every continuous real-valued function on $X$ is bounded, $X$ must be compact. This is the <bounded-continuous-function characterization of compact metric spaces>.
Back to article page