# Errors using Algorithm

When I run the following code, the pdf is getting generated but I get errors.

 \documentclass[12pt,a4paper,oneside,oldfontcommands]{memoir}
\usepackage{algorithm2e}
\usepackage{algorithmicx}

\begin{document}

The following is an example algorithm

\begin{algorithm}[ht!]
\caption{Algorithm}
Set count = 1 \linebreak

\While{count $\le$ V}{
count $\gets$ count + 1
}

\While{dataa $\ne \phi$}{
\For{V $\epsilon$ data}
{   \For{a \textless d}
{   \If{ccc}
{
statements;

}
\ElseIf{cond2}
{
statements;
}
\EndIf
}   \EndFor
}   \EndFor

}
\end{algorithm}
\end{document}


Don't mix algorithmicx and algorithm2e. Use one or the other. Here's what you would use with the latter:

\documentclass{article}
\usepackage{algorithm2e,amsmath}

\begin{document}

The following is an example algorithm

\begin{algorithm}[ht!]
\caption{Algorithm}
Set $\text{count} = 1$\;
\While{$\text{count} \leq V$}{
$\text{count} \gets \text{count} + 1$
}
\While{$\text{data} \neq \phi$}{
\For{$V \in \text{data}$}{
\For{$a < d$}{
\If{ccc}{
statements\;
}
\ElseIf{cond2}{
statements\;
}
}
}
}
\end{algorithm}

\end{document}

• Also there are no \endIF and \EndFor. I did not follow the basic syntax. Thanks for the help Commented Jun 20, 2014 at 4:29