Prove that $$f(x) = \begin{cases} x^2 & \text{ if } x\in \mathbb{Q} \\ 0 & \text{ if } x\in \mathbb{Q}^{c} \end{cases}$$ is continuous at $0$ and discontinuous everywhere else
Proof: First I want to prove that the function is continuous at $0$.
Suppose that $\lim_{n \rightarrow \infty} x_{n} = 0$, then
$\lim_{n \rightarrow \infty} f(x_{n}) = \lim_{n \rightarrow \infty} x_{n}^{2} = f(0)$
Therefore, the function $f$ is continuous at $0$. Now to prove that it's discontinuous everywhere else. For $x_{0} \neq 0$, based on the density of rational and irrational numbers in $\mathbb{R}$,
$\exists r_{n} \in \mathbb{R}$ such that $r_{n} \rightarrow x_{0}$ and
$\exists s_{n} \in \mathbb{Q}^{c}$ such that $s_{n} \rightarrow x_{0}$, so
$\lim_{n \rightarrow \infty} f(r_{n}) = f(x_{0}) = x_{0}^2$ and
$\lim_{n \rightarrow \infty} f(s_{n}) = f(x_{0}) = 0$. Since $x_{0}^2 \neq 0$ for $x_{0} \neq 0$, the function is discontinuous everywhere else. $\square$
Is my proof correct?