I am trying to compile the following code and trying to get spaces at start of code using spacing commands \hspace{2em}, \qquad and \indent. But space does not show up instead all things are being printed as normal lines. I am working with PDFLaTeX.
\documentclass[11pt]{article}
\begin{document}
\begin{enumerate}
\item Initialize beg=0 and end=length-1.
\item Repeat step 8 till low high.
\item Middle =(low + high) / 2.
%%%%%%% I need Space Hereafter %%%%%%%
\item if searcharray[middle]=searchno \\
\indent\indent Search is successful \\
\indent return middle. \\
else if searcharray[middle]$>$searchno[end] \\
\indent end=middle - 1 \\
else \\
\indent beg=middle + 1. \\
\end{enumerate}
\end{document}

enumerate, you can have a look at the wonderful packages for this purpose https://en.wikibooks.org/wiki/LaTeX/Algorithms, Write pseudo code in latex and Writing an algorithm in LaTeX. If it is source code you are writing, consider https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings and http://texblog.org/2008/04/02/include-source-code-in-latex-with-listings/. – moewe Aug 22 '15 at 14:26\indentis used again and again. – Soumyajit Aug 22 '15 at 15:29\indentis just not how you indent with the algo packages. The indentation is done by nesting. Please update your question with what you use now (what pacakge did you end up using?), and make what you want to acheive a bit more precise (I'm guessing you want horizontal indentation, but am not too sure.). See also Indenting lines of code in algorithm, Change Indentation Size in algorithmicx package. – moewe Aug 22 '15 at 15:31\indentdoesn't produce any indentation inside a list and also offering some advise on typesetting pseudo-code. – Gonzalo Medina Aug 22 '15 at 17:58\hspace*{2em}– touhami Aug 22 '15 at 18:01