suppose that the function g:R->R is continuous and that g(x)=0 if x is rational. Prove that g(x)=0 for all x in R.
-- I am totally stuck on this one.
Since you have $\displaystyle g(x)=0$ when $\displaystyle x \in Q$, suppose that $\displaystyle x \in R-Q$. You should know that the rationals are dense in $\displaystyle R$, so there is a rational $\displaystyle x_n \in \left( x-\frac{1}{n}, x+\frac{1}{n}\right)$. so..
Can you try to complete?
Maybe even more simply. We have by the continuity of $\displaystyle g$ that $\displaystyle g^{-1}(\{0\})$ is closed. Thus, $\displaystyle \mathbb{R}\supseteq g^{-1}(\{0\})=\overline{g^{-1}(\{0\})}\supseteq\overline{\mathbb{Q}}=\mathbb{R }$ so that $\displaystyle g^{-1}(\{0\})=\mathbb{R}$
For a beginner here is a different proof.
If a continuous function is not zero at a point then there is an open interval containing the point on which the function has the same sign (either positive or negative throughout the interval). But every interval contains a rational number.
So this function has to be zero everywhere.