Suppose $x_n$ tends to $x$, but $f(x_n)$ does not tend to $f(x)$. Then there is a neighbourhood $(f(x)-\epsilon, f(x)+\epsilon)$ which $f(x_n)$ misses infinitely often. WLOG $f(x_n)>f(x)+\epsilon$ for infinitely many $n$. Hence $f(y)>f(x)+\epsilon$ for $y$ arbitrarily close to $x$. But then, for any $a$ in $(f(x),f(x)+\epsilon)$, the intermediate value property tells us that $f$ takes the value $a$ at points arbitrarily close to $x$. By our other assumption, at least one such $a$ has closed preimage. Contradiction.
If I understood the OP correctly, he wants some simple examples of functions, which are not continuous and they have Darboux property. (He wants to practice showing that a function has intermediate value property on some concrete examples.)
I've given a few examples. I have made this post CW, so feel free to add further examples.
Functions which are not continuous, but are derivatives:
$f(x)=
\begin{cases}
\sin\frac1x, & x\ne 0, \\
0 & \text{otherwise}.
\end{cases}
$
$g(x)=
\begin{cases}
2x\cos\frac1x+\sin\frac1x, & x\ne 0, \\
0 & \text{otherwise}.
\end{cases}
$
$h(x)=
\begin{cases}
2x\sin\frac1{x^2}-2\frac1x\cos\frac1{x^2}, & x\ne 0, \\
0 & \text{otherwise}.
\end{cases}
$
The functions $f(x)$, $g(x)$ are $h(x)$ are from the book Van Rooij-Schikhof: A Second Course in Real Analysis (in the Introduction.).
Functions which are not continuous, but have Darboux property (intermediate value property):
$f_2(x)=
\begin{cases}
\sin\frac1x, & x\ne 0, \\
1 & \text{otherwise}.
\end{cases}
$
Again from the book Van Rooij-Schikhof: A Second Course in Real Analysis (in the Introduction.).
Best Answer
suppose $f$ has at least one discontinuity point $x$, i.e. $$ (\exists\epsilon>0)(\forall\delta>0)(\exists x'\in(x-\delta,x+\delta))\quad|f(x')-f(x)|\ge\epsilon\text; $$ in particular, for each $n\in\mathbb N$ we can choose $x_n$ so that $$ |x_n-x|<\frac1{n+1}\quad\&\quad|f(x_n)-f(x)|\ge\epsilon\text; $$ choose $$ r_+\in(f(x),f(x)+\epsilon)\cap\mathbb Q \\ r_-\in(f(x)-\epsilon,f(x))\cap\mathbb Q $$ then, by the IVP, there exists some $y_n$ between $x_n$ and $x$ such that $$ f(y_n)=r_+\quad\text{or}\quad f(y_n)=r_- $$ (depending whether $f(x_n)>f(x)$ or $f(x_n)<f(x)$); in particular, $$ y_n\rightarrow x\text; $$ suppose the '$+$' case occurs infinitely often (otherwise consider the '$-$' case): the corresponding subsequence lies in $f^{-1}(r_+)$ (closed by assumption), thus $$ f(x)=r_+\text, $$ in contradiction to the choice of $r_+$. this shows that no discontinuity point exists, i.e. $f$ is continuous.
EDIT my previous attempt (below) was wrong, disregard
consider the preimage of $I\cap\mathbb Q$, where $I=[a,b]$, and show that its closure is the preimage of $I$.
for any $x\in \overline {f^{-1}(I\cap\mathbb Q)}$ take a sequence $\{x_n\}$ in $f^{-1}(I\cap\mathbb Q)$ converging to $x$. then either infinitely many $x_n$'s lie in one of the $f^{-1}(r)$'s, or each $f^{-1}(r)$ only contains finitely many $x_n$'s (so the sequence intersects infinitely many $f^{-1}(r)$'s).
in the first case, the subsequence lying in $f^{-1}(r)$ (closed) converges in this set, so $x\in f^{-1}(r)$.
in the second case, construct a sequence $\{r_m\}$ and show $$f(x)=\lim_{m\rightarrow\infty}r_m$$