Conditional operator




Want to learn how to create powerful, "intelligent", versatile and useful programs?

Then you need to learn the three main forms of process control. According to the theory of computing systems, a good programming language should provide the implementation of three forms of control over the process of program execution:
1 - SEQUENCE:  Executing sequential statements - we’ve already seen this in earlier courses. All our previous programs were a sequence of statements
2 - ВЫБОР:
         if such and such a case,
               then do it
         else do that
3 - REITERATION:
          WHILE (as long as such and such cases - do it)

The program is becoming more “intelligent,” and also greatly increases the efficiency of computers in the second form - the CHOICE between different methods of action.

Let's start with a simple example.
It is necessary to enter two real numbers from the keyboard and determine the largest of them.
Parse this example.

ЗАДАЧА
By the condition of the problem, we need to output one of two answers: if the first number is greater than the second, then display it, if not, then the second number
Consider the first solution to this problem: the result is immediately outputed on the screen.

1. Run the program for execution.
2. Analyze the input and output data.

Ответ:

     
Результаты проверки: