I am confused with the conditional operator If then else, I enter

Program help2; var a,b,c:LongInt; begin ReadLn(a); ReadLn(b); a:= ( b < c ); // и тут я не понял If then else 

In theory, I enter 1 and 2, and I have to show the 2 the largest number!
I do not know how to output the largest number with If then else.

  • @ChokaLatkA, To format the code, select it with the mouse and click on the {} button of the editor. @ChokaLatkA, Try to write more detailed questions. Explain what you see the problem, how to reproduce it, etc. - DreamChild
  • @ChokaLatkA, If you are given a comprehensive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky

1 answer 1

(b <c) is a logical expression whose result can be either true or false . You are trying to assign a logical expression to an integer type variable, which leads to a compilation level error - is absurd, for one data type you are trying to assign an expression to another data type.

The if then else construct looks like this:

 if <услове> then <оператор/выражение, которые будут выполняться, если условие - истинно> else <оператор/выражение, которые будут выполняться, если условие - ложно> 

Those. first, the condition is checked, if it is true (test result = true), then the operator is executed (statement block) followed by then , otherwise (if the condition is false), the statement is executed (statement block), followed by else .

For example:

 if (4 > 3) then writeln('4 > 3') else writeln('Не может быть такого, чтобы 3 было больше 4.'); 

The condition is checked (it may not necessarily be simple). In the example, this is 4> 3, since 4 is greater than 3, then the result of the condition check will be true, so the writeln ('4> 3') is executed and the screen displays: 4> 3.