If $A$ is dense, prove that $f(x) = 0$ 
Let $A$ be a dense subset of $\mathbb{R}$. That is, a set such that every open interval contains an element of $A$. Assume $f$ is a continuous function on $\mathbb{R}$. Prove that if $f(x) = 0$ for all $x \in A$, then $f(x) = 0$ for all $x \in \mathbb{R}$.

My approach to this question was showing maybe that a dense set of $\mathbb{R}$ is in some must be $\mathbb{R}$. Otherwise if it were some smaller interval the then $f(x) = 0$ for all $x \in \mathbb{R}$ may not necessarily be true. But how do I show that $A = \mathbb{R}$?
 A: Since this is tagged as calculus, let's do $\epsilon$-$\delta$ and contradiction.
Assume that there is an $x \notin A$ such that $f(x) \neq 0$. Now, take $\epsilon = \frac{|f(x)|}2$. Then the definition of continuity of $f$ at the point $x$ gives us a $\delta > 0$. But the open, non-empty interval $(x-\delta, x+\delta)$ contains some point $a \in A$ (since $A$ is dense), and we have $f(a) = 0$. This means that
$$
|f(x) - f(a)| = |f(x)| = 2\epsilon \not < \epsilon
$$
even though $|x-a| < \delta$, which contradicts the continuity of $f$.
A: Let $x \in \mathbb{R}$ and take $(a_n)_{n=1}^\infty \subset A$ with $a_n \to x$. Then, $f(a_n) = 0$ for all $n$. By continuity, $f(x) = \lim_{n \to \infty} f(a_n) = \lim_{n \to \infty} 0 = 0$. 
This can be generalized! For any metric space $X$ (or Hausdorff topological space; if you don't know what these are, replace the term "metric space $X$" with $\mathbb{R}$) and $A\subset X$ dense, if two functions $f$ and $g$ agree on $A$ then they agree on all of $X$.
