Here is the question:
Let $J \subset \mathbb{R}$ be a interval. Let $f\colon J \to \mathbb{R}$ be continuous and $f(x) \ne 0$ for all $x \in J$. Show that $f > 0$ on $J$ or $f<0$ on $J$.
Here's what I tried: Suppose it is not the case that $f<0$ on $J$. Then $f(x)\ge 0$ for all $x \in J$. But then $f(x)\ne 0$ for any $x \in J$, hence $f>0$ on $J$ and it is done. But then I never used intermediate value theorem. Is my proof correct?
This question has been given as an application of the intermediate value theorem.
EDIT: Suppose it is not the case that $f<0$ on $J$. Then $f(b)\ge 0$ for some $b \in J$. But since $f(x)\ne 0$ for all $x \in J $, thus $f(b)> 0$. Now we show that $f(x) >0$ for all $x \in J$. Suppose there was some $a \in J$ such that $f(a)<0$. Then since $f(a) < 0 < f(b)$ and $f$ is continuous on $[a,b] \subset J$, there exists $c \in J$ such that $f(c)=0$, thus a contradiction!