In the problem of finding the maximum number of two, we met a new operator that began with the word IF
This operator is called - CONDITIONAL
The word if is translated from English as "if", and the word else - as "otherwise". If the condition after the word if is true (true), then all commands (operators) following the condition after the word
then between the words
begin and
end are executed >. If the condition is false (false), then the commands between
begin and
end after the word else are executed.
GENERAL VIEW OF THE CONDITIONAL OPERATOR:
if condition then begin // header with condition
... // "if" block — statements that are executed
// if the condition in the header is true
end
else begin
... // "else" block — statements that are executed
// if condition in brackets is false
end;
REMEMBER:
1. IF - ELSE -
THIS IS ONE OPERATOR!
Therefore, no other statements
2. after the word
else NEVER CONDITION.
Block "otherwise" is executed when the main condition specified after the word IF - is false, i.e. not executed
3. In case, in the "if" block or in the "otherwise" block there is only one statement, then
begin and
end can be omitted
4. A CONDITION is an expression relative to which you can say it is true (that is, it is fulfilled) or false (that is, it is not fulfilled)
You can use logical relationship signs in a condition
> , < more less
>=, <= greater than or equal to, less than or equal to
= equals
<> not equal