Give an example of a topological space $X$, and a connected component which is not open in $X$
Take $$X=\mathbb{Q}$$ the rationals numbers with the Euclidean topology.
The space $\displaystyle X = \Big \{\frac{1}{2}, \frac{1}{3}, \ldots, 0 \Big\}$ is completely disconnected. That is to say the connected components are the singletons $\displaystyle \Big \{\frac{1}{2}\Big\}, \Big \{\frac{1}{3}\Big\} \ldots $ all of which are open, and $\{0\}$ which is not.
To show $\{0\}$ is not open observe the series $\frac{1}{2}, \frac{1}{3}, \ldots$ converges to zero, so is eventually in any open set about $0$. Therefore $\{0\}$ fails to be open. To show $\{0\}$ is a component observe that for each $n$ we can write $X=\Big \{\frac{1}{2}, \frac{1}{3}, \ldots, \frac{1}{n} \Big \} \cup \Big\{\frac{1}{n+1}, \frac{1}{n+2}, \ldots , 0 \Big\}$. This demonstrates that $\displaystyle\frac{1}{n}$ and $0$ are in different components.