I am using the algorithmic package to write algorithms. I want to have a link to the line of the algorithm like I can do to formulas using \label and \ref.

-

You can number the lines and then use the standard \label, \ref mechanism:

\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic}

\begin{document}

As we can see in line~\ref{alg:line} of Algorithm~\ref{alg:test}...

\begin{algorithm}
\begin{algorithmic}[1]
\STATE $S \leftarrow 0$
\STATE $T \leftarrow 1$\label{alg:line}
\STATE $U \leftarrow 2$
\end{algorithmic}
\caption{A test algorithm}
\label{alg:test}
\end{algorithm}

\end{document}


When the hyperref package is loaded, you will get hyperlinks. If you don't want to number the lines of the algorithm, but you want to generate a hyperlink to some particular line(s), then you can use the \hypertarget, \hyperlink mechanism provided by the hyperref package:

\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{hyperref}

\begin{document}

As we can see in \hyperlink{alg:line}{the second line} of Algorithm~\ref{alg:test}...

\begin{algorithm}
\begin{algorithmic}
\STATE $S \leftarrow 0$
\hypertarget{alg:line}{\STATE $T \leftarrow 1$}
\STATE $U \leftarrow 2$
\end{algorithmic}
\caption{A test algorithm}
\label{alg:test}
\end{algorithm}

\end{document}

-