Solution: It is clear that the function is continuous away from zero (as $\cos $ and $\frac{1}{x}$ both are continuous away from zero). We will prove that $f$ is not continuous at $x = 0$. For that let us use the sequential criteria for continuity. We know that if $f$ is a continuous function at $x$, then for every sequence $(x_n)$ if $x_n \rightarrow 0$, then $f(x_n) \rightarrow f(0).$ Consider the sequence
\[
x_n = \frac{1}{2\pi n}, \ n\in \mathbb{N} \implies x_n \to 0.
\]
Now consider the sequence $f(x_n)$.
\begin{align*}
f(x_n) = \cos \left( \frac{1}{x_n} \right) = \cos (2\pi n) = 1 \neq f(0).
\end{align*}
Thus, the function is not continuos at $x = 0$.