Regarding sup and inf of a continuous function Suppose $f:\mathbb R\to \mathbb R$ be a continuous function such that $\lim\limits_{x\to \infty}f(x)=0=\lim\limits_{x\to -\infty} f(x)$. Then I want to show that $f$ is bounded and attains at least one of $\inf$ and $\sup$.
For boundedness I did as follows:
Let $f$ be unbounded. Then for each $n>0$ there exists a sequence $(x_n)$ such that $\vert f(x_n)\vert>n$. Now if $(x_n)$ converges, by continuity of $f$, $(f(x_n))$ must converge. But this not possible as $(f(x_n))$ is unbounded. If $x_n\to \infty$ or $x_n\to -\infty$, then also by continuity of $f$, we can show contradiction. If $(x_n)$ does not converge, then it has a convergent subsequence which also leads to a contradiction. Hence $f$ must be bounded.
Now please help me to solve the next part of the problem. To my understanding, if I suppose that $m<f(x)<M$ for all $x\in \mathbb R$, where $M=\sup f(x)$ and $m=\inf f(x)$, then this will lead to a contradiction. But I could not show that.
 A: If $f=0$ then we are done.
Otherwise suppose $\exists x_0$ s.t. $f(x_0)>0$. Then we argue $f$ must obtain its sup.
Since $\lim_{|x|\to\infty}f(x)=0$, $\exists M>0$, such that $|x|>M, |f(x)|<\frac{f(x_0)}{2}$, then you can argue the $f$ is bounded(discuss the cases for $|x|\le M$ and $|x|>M$). 
Hence the sup exists. Moreover, $f$ can't obtain sup at $|x|>M$, because $\sup f\ge f(x_0)>0$. Then  we can argue the maximum of $f$ on $[-M,M]$ is indeed the sup of $f$ on $\mathbb{R}$.
For $f(x_0)<0$, use similar method to discuss inf or just consider $-f$.
A: Anupam, this is not such an answer but I think it will help to clarify. 
When you wrote, in the 1st paragraph, f:R→Rf:R→R  be a continuous function such that $\lim\limits_{x\to \infty}f(x)=0=\lim\limits_{x\to -\infty} f(x) \quad$,
I think you misunderstood two different concepts, or , your notation is not good to express what it means.
Let me explain:
this notation $\lim\limits_{x\to -\infty}f(x)=0\;$ means that the global limit of the function when x trends to $ -\infty $ equals zero; in the other hand, this notation $\lim\limits_{x\to \infty-} f(x)=0 \;$  means that the limit of the function when x trends from the left to $ \infty \;$(or formally +$\infty$) equals zero. This kind of limit is usually called lateral limit.
By definition, a global limit only exists if both lateral limits have the same  result. And, a function is continuos, at a particular point, if its value is equal to the global limit (or both lateral limits) at that point. So your 1st paragraph probably should be $\lim\limits_{x\to \infty+}f(x)=0=\lim\limits_{x\to \infty-} f(x) \quad$ what has a similar notation with that you wrote, but totally different meanings.
