Define $$ f(x) = \begin{cases} 1, & \text{if $x > 0$ } \\ -1, & \text{if $x < 0$ } \\ c, & \text{if $x= 0$ } \end{cases} $$ Assume $f$ is continuous at $x=0$.
Take $\epsilon= 1$. So, whenever $x \in (-\delta, +\delta)$ , $c - \epsilon < f(x) < c + \epsilon $.
So pick $x_1, x_2 \in (-\delta,\delta)$, such that $f(x_1) = -1$ and $f(x_2) = -1$.
So we have , $c-\epsilon <1 < c+\epsilon$ and $c-\epsilon <-1 < c+\epsilon$.
Now using above two equations, $2= 1+1 < 2\epsilon$ or $ \epsilon >1$ which is contradiction
Is it correct way ? Is there better way to do this ? Thanks
Your solution looks fine, except you should change $f(x_1)=-1$ to $f(x_1)=1$, or change $f(x_2)$.
Here's another way to do it, without proof by contradiction. We will prove the negation of continuity at $0$ directly.
Take $\varepsilon=1$. Let $\delta>0$. Take $x=\delta/2$. Then $f(x)=1$, $f(-x)=-1$, $f(0)=c$.
If $c\ge 0$, then $|f(-x)-f(0)|=|{-1}-c|=c+1\ge 1=\varepsilon$.
If $c<0$, then $|f(x)-f(0)|=|1-c|=1-c\ge 1=\varepsilon$.
Thus, in any case, there exists some number $y$ in $(-\delta,\delta)$ such that $|f(y)-f(0)|\ge \varepsilon$. This proves the discontinuity of $f$ at $0$.