Let $[a, b]\subset\Bbb{R}$ and let $c \in[a,b]$. Prove that there exists a sequence of rational numbers $(r_n)$ such that $\lim_{n\to\infty}r_n=c$ I do have a hint for this question, which says: For each $n\in\Bbb{N}$, choose a rational number in the interval $(c-\frac{1}{n}, c+\frac{1}{n})\cap[a,b]$.
This question also has another part which I can't seem to figure out either.
Let $[a,b]$ be an interval in $\Bbb{R}$ with $a < b$ and let $f:[a,b]\to\Bbb{R}$ be a function which is continuous on $[a,b]$. Prove that if $f(x)=0$ for every rational number $x$ in $[a,b]$, then $f(x)=0$ for all $x ∈ [a,b]$.
For the second one, I'm assuming that I'm basically proving that if $f(x)=0$ for every rational number, then $f(x)=0$ for every irrational number as well. I just don't know where to start with either of these.
 A: HINTS:
1) Every number has a decimal expansion, so can be approximated, this is a rational number and it tends to anything in the reals (I've overly simplified what all this means, but you can make it rigourous. 
Every real number is rational or irrational. If rational, sure we can use $c + \frac{1}{n}$ like you say, but we could also choose the sequence $c,c,c,c,c,\dots$, which converges a lot more obviously to $c$ and is a rational sequence.  
If it's irrational, then I want to construct a rational sequence which tends to it. Well, a number $x$ has a decimal expansion (check, this has to be well defined and so on). Say $x = x_n \dots x_3x_2x_1x_0.x_{-1}x_{-2}x_{-3}x_{-4}\dots$. What sort of rational sequence can I construct knowing this to get $x$? I have very literally constructed a sequence of rationals that will tend to any irrational number, I don't know how to make this more obvious without just giving you the answer.
2) Let's use the help of our great friends/enemies $\varepsilon$ and $\delta$, the iconic duo of the analysis world. Things are continous, but between every two rational people in analysis world, there is one who is irrational. And between every two irrational people, there is a rational person. (Prove it)
Let's say for contradiction sake that $f(x) \neq 0$ for some real number $x$.
Now we have a dichotomy (forced choice) that means $x$ is rational or irrational. If $x$ is rational, well $f(x)=0$ by construction.
So $x$ is irrational. But, $f$ is continuous, and there is $x_+,x_-$ above and below $x$ that are rational and arbitrarily close to it, and the value on $x_+,x_-$ are $0$. hmmm continuous, hmmm 0..., hmmm not going to do assignment questions until I see you've tried a lot, but will still give hints spelling out the answer... 
Name a continuous function that has a value at $1$ but in any epsilon neighbourhood of it, it's $0$. I double dare you to find such a function.
A: This question is a good example of a question which "builds" up through the various concepts it makes use of.
The author(s) intend for the reader to come up with a good understanding of the "connectedness" of the real line and how this eventually translates into the "connectedness" of continuous functions defined on such domains.
The first part is really a major hint for the main problem, which is the second part.
So, let's review the first part very quickly. To re-iterate


*

*$a < b$

*$[a,\ b] \subset \mathbb R$

*$c \in [a,\ b]$ is an indeterminate but fixed real number in that domain.


Although, we can technically pick the sequence $\{c,\ c,\ c, \cdots\}$ (if $c$ is rational), I think it's worthwhile pointing out that we can satisfy an even stronger condition here. Namely, that we can find a monotone increasing or monotone decreasing sequence which is contained entirely in $[a,\ b]$. Other conditions can also be satisfied.
That is where the example they gave comes handy. Though it isn't necessary, it's their way of encouraging you to pick such a sequence. Note, however, that expression for obtaining a sequence may not be helpful for certain combinations of $a, b$ and $c$. This can be easily remedied by using a sequence of rational numbers from intervals of the form $(c - n^{-k},\ c + n^{-k})$ for large enough $k.$
If I remember correctly, this is a Cauchy sequence in $\mathbb R$, which implies that it is convergent.
Now, the second part.
We will use a proof by contradiction. Our premise is:


*

*$f$ is defined and continuous on $[a,\ b],$ and

*$\forall x \in \mathbb Q \cap [a,\ b], f(x) = 0$.


Our contradiction will come from assuming the negation of the desired conclusion. So, the assumption toward contradiction is
$$\exists x_1 \in [a,\ b] : x_1 \not \in \mathbb Q \land f(x_1) \neq 0.$$
We need only prove this with the existence of exactly one such $x_1$.
There are other stronger claims to be made here, for example, there are finitely many ($> 1$) such irrational numbers in that interval, there are countably infinitely many such numbers, etc. But all of those cases are either trivial extensions of the case with a single point, or imply that the contradiction follows by definition.
For the case with a single point, notice we can get arbitrarily close to $x_1$ where as the difference $|f(x) - f(x_1)|$ does not get arbitrarily small for $x \in [a,\ b]$. This is one of the definitions of continuity.
Therefore, this contradicts the requirement that $f$ be continuous on the given domain. More precisely, take $f(x) = 0$ for $x \in [a,\ b]-\{x_1\}$, and $f(x_1) = d \in \mathbb R - \{0\}$. I'm going to assume boundary cases have been well accounted for. Q.E.D.
Interestingly enough, if we had assumed that there was more than one irrational number for which $f(x) \neq 0$, the contradiction would make more evident the need of the second of the original set of premises we listed.
Finally, if I have missed something, many apologies. Please feel free to point it out or ask further questions.
A: My answer works
for any dense set,
not just the rationals:
Suppose $f(x)$is a continuous function on $[0,1]$ such that $f(x)=x$, when $x$ is irrational in $[0,1]$. Show that $f(x)=x$ for all $x \in [0,1]$
Just replace
"$f(x) = x$"
with
"$f(x) = 0$".
A: Following the hint, let $r_n$ be a rational number in $(r-\frac1n,r+\frac1n)\cap[a,b]$. Then in particular, $|r_n-r|<\frac1n\to0$. Now follow marty cohen's answer for the second part.
