Node: else, Next: Empty, Previous: downto, Up: Reference

### else

#### Synopsis

As part of the `if` ... `then` ... `else` statement:

         if Boolean_expression then
           statement1
         else
           statement2

or, as part of the `case` ... `else` statement:

         case expression of
           selector: statement;
           ...
           selector: statement
         else  { ``otherwise'' instead of ``else'' is allowed }
           statement;
           ...
           statement
         end

#### Description

`else` is part of the `if ... then ... else` statement which provides a possibility to execute statements alternatively. In the `case` statement, `else` starts a series of statements which is executed if no selector fit in expression. In this situation, `else` is a synonym for `otherwise`.

#### Conforming to

`else` in `if` statements is defined in ISO 7185 Pascal and supported by all known Pascal variants. `else` in `case` statements is a Borland Pascal extension; ISO 10206 Extended Pascal has `otherwise` instead.

#### Example

         program ElseDemo;
         var
           i: Integer;
         begin
           Write ('Enter a number: ');
           ReadLn (i);
           if i > 42 then
             WriteLn ('The number is greater than 42')
           else
             WriteLn ('The number is not greater than 42')
         end.

#### See also

Keywords, if, case, otherwise.