Do you want to learn how to create powerful, "intelligent", versatile and useful programs?

Then you need to learn the three main forms of program execution control. According to the theory of computer systems, a good programming language should provide the implementation of three forms of control over the process of program execution:
1 - SEQUENCE:  Execution of sequential statements - we have already met with this in earlier courses. All our previous programs were some sequence of statements
2 - SELECT:
          if such and such a case,
              then do this
          otherwise do that
3 - REPEAT:
          WHILE

The program is becoming more "intelligent", and the second form - the CHOICE between different modes of action - greatly increases the efficiency of computers. 

Let's start with a simple example. 
You must enter two integers from the keyboard and determine the largest of them.
Explore this example.

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

 

Consider the second variant of solving the problem of finding the maximum of two numbers. 
In the second program, we will first write the maximum value to an additional  variable (let's name it Max)

If in the "else" block you don’t have to do anything (for example: “if there is ice cream on sale, buy ice cream”, and if not ...), then the entire block “otherwise” you can omit and use an abbreviated (incomplete) form of the conditional operator:
if condition then begin
   ... // what to do if condition is true
end;
Consider an example of solving the problem of finding the maximum of two numbers, using the incomplete form of the conditional operator