[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 9.68 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
      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 case, ``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

section 9.110 if, section 9.38 case, section 9.184 otherwise.

This document was generated by Frank Heckenbach on May, 10 2002 using texi2html