next up previous
Next: The for Loop Up: The pseudocode Environment Previous: The begin-end Construct

The if-then-else Construct

The if-then-else construct takes various forms, such as the following:

\IF <condition> \THEN <stmt> 
\IF <condition> \THEN <stmt> \ELSE <stmt> 
\IF <condition> \THEN <stmt> \ELSEIF <stmt> \THEN <stmt>
Note that there is no limit placed on the number of \ELSEIFs that may be used in an if-then-else construct. For example, the commands:
\IF some condition is true
\THEN
 \BEGIN
    some statement\\
    another statement\\
    yet another statement
 \END
\ELSEIF some other condition is true
\THEN
 \BEGIN
    some statement\\
    another statement\\
    yet another statement
 \END
\ELSEIF some even more bizarre condition is met
\THEN 
  do something else
\ELSE
  do the default actions

would produce the following output:



\begin{pseudocode}[display]{}{}
\IF \mbox{some condition is true}
\THEN
\BEGIN
...
...EN \mbox{do something else}
\ELSE
\mbox{do the default actions}
\end{pseudocode}



Donald L. Kreher
2000-02-18