**Step 1: Normalisation.** By translating and rescaling, we may assume $0 \le f(x) \le 1$ for all $x \in C$ with $\sup_{x \in C} f(x) = 1$.
**Step 2: Iterative approximation using Urysohn's Lemma.** Set $f_0 := f$. At stage $i$, given $f_i: C \to \mathbb{R}$ with $0 \le f_i \le (2/3)^i$, define $g_i$ on two disjoint closed subsets of $X$ by: $g_i \equiv 0$ on $f_i^{-1}([0, (2/3)^i / 3])$ and $g_i \equiv (2/3)^i / 3$ on $f_i^{-1}([2(2/3)^i/3, (2/3)^i])$. By [Urysohn's Lemma](/theorems/887), extend $g_i$ [continuously](/page/Continuity) to all of $X$ with $0 \le g_i \le (2/3)^i / 3$. Then set $f_{i+1} := f_i - g_i|_C$, which satisfies $0 \le f_{i+1} \le (2/3)^{i+1}$.
**Step 3: Define the extension.** Set $\tilde{f} := \sum_{i=0}^\infty g_i$. Since $0 \le g_i \le \frac{1}{3}(2/3)^i$ and $\sum_{i=0}^\infty \frac{1}{3}(2/3)^i = 1$, the [series](/page/Series) [converges uniformly](/page/Uniform%20Convergence) to a continuous [function](/page/Function) $\tilde{f}: X \to [0, 1]$. On $C$: $\sum_{i=0}^n g_i|_C = f_0 - f_{n+1} = f - f_{n+1}$, and $\|f_{n+1}\|_{C(C)} \le (2/3)^{n+1} \to 0$, so $\tilde{f}|_C = f$. The norm equality $\|\tilde{f}\|_{C(X)} = \|f\|_{C(C)}$ follows from the bounds $0 \le \tilde{f} \le 1 = \|f\|_{C(C)}$ and the fact that $\tilde{f}|_C = f$ attains the supremum.