Answer
See proof
Work Step by Step
We are given the function:
$f(x)=\begin{cases}
x,\text{ for }x \text{ rational}\\
-x,\text{ for }x \text{ irrational}
\end{cases}$
First we proved that $f$ is not continuous at $x_0\not=0$.
We take a sequence of rational numbers $x_n$ converging to $x_0$ and a sequence of irrational numbers $y_n$ converging to $x_0$. We see that $\displaystyle\lim_{x\rightarrow x_0} f(x)$ does not exist.
Then we prove that $f(x)$ is continuous in $x=0$.
$f(0)=0$
$-|x|\leq f(x)\leq |x|$ for all $x$.
$\displaystyle\lim_{x\rightarrow 0} (-|x|)=\displaystyle\lim_{x\rightarrow 0} |x|=0$
From the pinching theorem we get:
$\Rightarrow \displaystyle\lim_{x\rightarrow 0} f(x)=0$
This means that $f$ is continuous only in $x=0$.