If f is continuous for every real number and $f(r)=0$ for every rational number, then $f(x)=0$ for all real numbers.

Solution 1:

Since $\mathbb{Q}$ is dense in $\mathbb{R}$, for every real number $x \in \mathbb{R}$, there exists a sequence $(q_n)_{n=1}^\infty \in \mathbb{Q}$ such that $q_n \to x$ (for example, take the sequence of truncated decimal expansions). Then, by continuity, $$f(x) = f\left(\lim_{n \to \infty} q_n\right) = \lim_{n \to \infty}f(q_n) = \lim_{n \to \infty} 0 = 0.$$

Solution 2:

No, because you have not specified what $r$ is, in particular, $r$ is not necessarily a rational number, so $f(r)$ need not to be $0$. Rather, fix an irrational number $r$, since $f$ is continuous at $x=r$, given $\epsilon>0$, there exists some $\delta>0$ such that for all $x$ with $|x-r|<\delta$ we have $|f(x)-f(r)|<\epsilon$. Now choose a rational number $q$ such that $|q-r|<\delta$, plugging in, we have $|f(r)|=|f(q)-f(r)|<\epsilon.$ Since the latter inequality is true for all $\epsilon>0$, one has $|f(r)|=0$, so $f(r)=0$.