Is $A=\{y \in \Bbb{R}: y=\lim_{n\to \infty}f(x_n), \text{for some sequence}~ x_n \to +\infty\}$ compact for a continuous $f$? 
Question.  Let $f:\Bbb{R} \to \Bbb{R}$ be a continuous function and $A\subset \Bbb{R}$ be defined by 
  $$A=\{y \in \Bbb{R}: y=\lim_{n\to \infty}f(x_n), \text{for some sequence}~ x_n \to +\infty\}$$ 
  Then the set $A$ is necessarily
A. A connected set
B. A compact set
C. A singleton set
D. None of the above

My attempt. I don't have enough progress in this problem.
First, I want to understand the definition of $A$ properly. Since $f$ is given continuous, then for a sequence $(x_n)$ with $x_n \to +\infty$, $f(x_n)$ may converge or diverge to $+\infty$ or may be oscilatory. So, for a $(x_n)$ with $x_n \to +\infty$ if it happens that $f(x_n)$ is convergent then we collect that limit, $\lim f(x_n)$, in the set $A$.
Now if we take $f(x)=\cos\pi x$ and $x_n=2n+1, y_n=2n$ then both $x_n,y_n\to +\infty$ but $\lim f(x_n)=-1$ and $\lim f(y_n)=1$. So, $\{1,-1\} \subset A$. Therefore Option C is False.
Now I try to prove Option A:
To prove $A$ to be connected I have to show that any continuos function $g: A\to \{\pm 1\}$ is constant. But I cannot proceed with this further. 
So I try to prove: $A=cl(B)$ for some connected set $B \subset \Bbb{R}$. Now looking on the description of the set $A$ I try to find out $B$. It seems $B$ should contains all $f(x_n)$'s for some $x_n \to +\infty$. Since, every such $(x_n)$ can be made $>1$ after all but finitely many terms, so $B=\{f(x):x>1\}=f((1,+\infty))$. Since $f$ is continuous so $B$ is connected being continuous image of a connected set and so is $A=cl(B)$. Therefore, Option A is True.
But I cannot conclude Option B. Please help me in B. Is this solution correct? Please tell  if there is any mistake in my solution.
 A: I think the understanding of the question is hampering your progress here. 
The meaning of $x_n \to +\infty$ is that for all $r > 0$ there exists $N$ such that $n > N$ implies $x_n > r$. In other words, $x_n$ is eventually larger than every real number.
Now, we are asking if $f(x_n)$ has a limit for any such sequence $x_n \to + \infty$. $A$ is the set of all such limits.

To see the intuition for $A$, try to think of points that would obviously belong to $A$. For example, if there is a sequence $x_n \to +\infty$ such that $f(x_n)$ are all equal. Then, this number will be in $A$.
This allows us to construct $\sin x$ as a counterexample to $A$ being a singleton : it is periodic, so $A$ is the range of this function, which is not a singleton.

For connectedness, you seem to have  made a mistake in interpreting $A$. $A$ does not contain $f(x_n)$ for any sequence $x_n \to +\infty$, but rather any limit point that may arise from a choice of $x_n$ for which this is convergent. Points of a sequence are not its limit points, therefore we must be more careful in this aspect.
To show that $A$ is actually connected, we note that $A$ is a subset of the real numbers, and here we have the description that $A$ is connected if and only if it is an interval. This is what must be used : suppose that $a < c < b$ is there with $a,b \in A$, then show that $c \in A$ as well. This is the definition of an interval.
If $a,b \in A$, then there exist two sequences $x_n , w_n \to \infty$ such that $f(x_n) \to a$ and $f(w_n) \to b$. We want to construct $z_n$ such that $z_n \to \infty$ and $f(z_n)$ goes to $c$.
Let us perform a trimming : Let $y_n$ be a subsequence of $w_n$ defined as follows : $y_n = w_{l_n}$, where $l_n = min\{ k > l_{n-1} : w_{k} > x_n\}$, with $l_0 = 0$. Now, $y_n \to +\infty$ (why?) and $y_n > x_n$ (why?). Furthermore, a subsequence of a convergent sequence is convergent, so $f(y_n) \to b$.
First, denote $\delta = \frac{\min(c-a,b-c)}{2}$. Then, by definition of $f(y_n) \to b$ we have $N$ such that $f(y_n) > b-\delta > c$ for $n > N$. Similarly, we have $f(x_n) < a+\delta < c$ for some $n > M$. Taking the maximum, we have for $L = \max \{N,M\}$ that $n > L$ implies $f(x_n) < c < f(y_n)$.
Now, by the intermediate value theorem (applied infinitely many times) for each $x_n < y_n$, after $n > L$ there exists a $z_n$ in between such that $f(z_n) = c$, since $c$ lies between $f(x_n)$ and $f(y_n)$. Reindex $z_n$(it is now defined only for $n> L$) to start from $1$ by shifting. This $z_n$ goes to $+\infty$ (why?) , however we even get that $f(z_n) \to c$ , because it is the constant sequence $c,c,...$!
Hence, the connectedness follows.

As for compactness, the idea is that a compact set is bounded. A continuous function can possible have very wild oscillaing behaviour (if you have seen $\sin \frac 1x$ near zero, like that) near infinity. This oscillating behaviour, like $\sin x$, leads to the creation of many elements of $A$. If this oscillation can be made unbounded, then $A$ can possibly be made unbounded!
That is the thinking behind the counterexample function $x \sin x$.
If you look at this function, it will have increasing oscillation with increasing $x$. This increasing oscillation means, that if you draw a horizontal line at any height on the grid, it will intersect the graph of this function at infinitely many points, starting from some point onwards, and will have a subsequence increasing to infinity.
To prove this a little more rigorously, we will show that $A = \mathbb R$ in this case, with a few steps skipped.
The easy way to see this is to see that $f(n\pi + \frac \pi 2) = n\pi + \frac \pi 2$, and $f(n \pi - \frac{\pi}{2}) = n \pi - \frac \pi 2$ for every $n \geq 1$, so you have two subsequences going to infinity : now use the intermediate value theorem like we did for connectedness between these points to conclude that every point has in its preimage a sequence going to infinity.
