Could anyone show me by an example how to produce ''end if'', ''end for'', and ''end while'' in the algorithm2e environment? Hello, thank you for your answer, I have tried to upload the algorithm which I want to write In the algorithm2e environment, I have also tried doing some portion of that but could you please help me to make it error-free and completed? Thanks
\documentclass[11pt]{article}
\usepackage[margin=3cm]{geometry}
\usepackage[ruled, noline]{algorithm2e}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}
\SetKw{KwBy}{by}
\SetAlgoLined
\DontPrintSemicolon
$k\gets 0$
$M_a\gets 0$
$M_b\gets 0$
\lWhile{something}{
\For{$p \in \{a,b\}$}{
\lIf{something}{
$M_p \gets M_p +1$
something
\Else
\If{M_p=M}{
something
\EndIf
\Else{something}
}
}
}
$k\gets k + 1$
\If{$M_a = M$ and $M_b = M$}{
$M_a \gets 0$
$M_b \gets 0$
}
}
\end{algorithm}
algpseudocode
along withalgorithm2e
and don't mix syntax: the two packages are different and don't go along together.