Let $f: \mathbb{R} \rightarrow \mathbb{R}$ be a continuous function. Suppose $x_0 \in \mathbb{R}$ and $f(x) = 0$ for all $x \gt x_0$. Prove that $f(x_0) = 0$.
My try: Let $a_n = x_0 + \frac{1}{n}$. So we have $\displaystyle \lim_{n \to \infty} a_n = x_0 $ and $\displaystyle \lim_{n \to \infty} f(a_n)= 0$. By continuity we have $\displaystyle \lim_{n \to \infty} f(a_n) = f(\lim_{n \to \infty} a_n) = f(x_0)$. The result is $f(x_0) = 0$.
Is this solution correct? What are the different ways to prove that? Also I wonder if it's possible to prove $f(x_1) = 0$ for $x_1 \lt x_0$ by the same argument.
Your solution is correct. However your claim about $x_1$ is not. Consider:
$$f(x)=\begin{cases}x_0-x &\text { for } x < x_0 \\ 0&\text{ for } x\ge x_0\end{cases}$$
$f$ is continuous but $\ne 0$ for any $x < x_0$.