Pseudo code for this algorithm

I am new to LaTeX ... I have searched many examples of algo pseudocode for this type of code.I don't know which package to use to write this algorithm.

• Hello you can use The Listings Package : ctan.org/pkg/listings – flav Mar 6 '16 at 7:19
• @flav: The listings package might work, but there are better ones for this particular task: algorithmic, algorithm2e etc. – user31729 Mar 6 '16 at 7:30
• Welcome to TeX.SX! What kind of documentclass do you prefer? – user31729 Mar 6 '16 at 7:32
• @flav can u please give me the link of code examples – Udit Kumawat Mar 6 '16 at 7:46

Here is a simple example with algorithm2e.You can find more about it in the documentation in CTAN.

\documentclass{article}
\usepackage[linesnumbered]{algorithm2e}

\begin{document}
\begin{algorithm}[htb]
\caption{An Algorithm}
\label{alg:algo1}

\KwIn{Some input}
\KwOut{Some Output}

$F_{i}\leftarrow0$\;
Do something\;
\For {$i=1$ \thinspace to 100}{
Do something one thing\;
$F_{i}\leftarrow F_{i} + 1$\;
}
\end{algorithm}
\end{document}


Here a very simple example with perl :

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}

\usepackage{listings}

\begin{document}
\lstset{language=perl, numbers=left}
\begin{lstlisting}
#!/usr/bin/perl
## flav
## 2003-08-05
##

sub usage
{
my  $num_arg;$num_arg = $#ARGV; if ($num_arg)
{
print "Usage: $0 name_of_program\n"; exit(-1); } } sub rl { my$exe;

usage();
$exe =$ARGV[0];
while (1)
{
if (fork())
{
wait();
}
else
{
sleep 600;
system("date");
exec(\$exe);
}
}
}

rl();

\end{lstlisting}

\end{document}


You will find all the doc : https://www.ctan.org/pkg/listings

But Chritan Hupfer is right there are some better package for your specific matter