Real analysis Limits and continuous functions Suppose that $f:\mathbb{R}\to \mathbb{R}$ is continuous on $\mathbb{R}$ and that $$
\lim_{x\to -\infty} f(x)=\lim_{x\to +\infty} f(x) =k$$ Prove that $f$ is bounded and if there exist a point $x_0 \in\mathbb{R}$ such that $f(x_0)>k$, then $f$ attains a maximum value on $\mathbb{R}$.
Edit by non OP. The OP seems to be a new user that posted the same question twice in less than 2 hours, both on MSE.
Real analysis continuous functions
 A: Since $f$ has finite limits at the infinities:
$\forall \varepsilon>0, \exists M_1, M_2>0: \forall x>M_1, \forall x<-M_2, |f(x)-k|<\varepsilon$
Therefore, we can see that in the sections $(M_1, \infty), (-\infty, -M_2)$, $f$ is bounded due to the definition of the limit (from $|f(x)-k|<\varepsilon$.
In addition, let's note that $[-M_2, M_1]$ is a compact set, and therefore, according to Weierstrauss's theorem, $f$ is bounded in that section and receives a minimum and maximum. 
From here, I'll let you figure out the second section just for the challenge.
A: Both proofs are similar and could be done assuming the opposite and getting a contradiction. 
So, first assume $f$ was not bounded. Then (without loss of generality, replacing $f$ with $-f$ if necessary) we may pick points $a_n$ such that $f(a_n)>n$. This sequence 
of $a_n$ must be bounded for otherwise it would contain either a sequence that goes to $\infty$ or a sequence that goes to $-\infty$, but in the former case, say 
$a_{n_j}\to\infty$ as $j$ goes to $\infty$ we get a contradiction since 
$f(a_{n_j})\to\infty$ but it is supposed to be that $f(a_{n_j})\to k$. If 
$a_{n_j}\to-\infty$ we get a similar contradiction. So, 
the sequence $a_n$ is bounded, and hence we may pick a converging subsequence, 
say $a_{n_m}\to x$ for some $x$, as $m\to\infty$. But then the contradiction is that 
$f(a_{n_m})\to\infty$ as $m\to\infty$, and by continuity at the same time 
$f(a_{n_m})\to f(x)<\infty$. 
For the other part assume that $f(x_0)>k$ for some $x_0$. We already proved that 
$f$ is bounded, so we could define $M=\sup\{f(t): t\in\mathbb R\}<\infty$. Then there is a sequence $b_n$ such that $f(b_n)>M-\frac1n$. The sequence $b_n$ must be bounded, 
for otherwise we could pick a subsequence $b_{n_j}$ that either goes to $\infty$ or to $-\infty$, as $j\to\infty$. But that would be a contradiction, as 
$f(b_{n_j})\to M$ as $j\to\infty$, and at the same time $f(b_{n_j})\to k$ with 
$k<f(x_0)\le M$. So, the sequence of the $b_n$ is bounded and we may pick a converging subsequence $b_{n_m}\to y$ for some $y$, as $m\to\infty$. 
Then by continuity $f(b_{n_m})\to M=f(y)$, so the maximum $M$ is attained at $y$. 
A: Technically, to do this proof constructively you need to know the value $k'$ that $f$ takes on where $k' > k$. Once you know that, choose $M$ so that $|f(x) - k| < |k' - k|$ for all $|x| > M$. Then the maximum occurs on the closed interval $[-M, M]$ and there is a global maximum somewhere there because $[-M,M]$ is compact.
