I attend 1st grade of Highschool. Recently I had an assignment to do in Turbo Pascal and this happened:
var
a,b,x,y,n:integer;
begin
readln(a,b,x,y);
if a<b and x<y then n:=a+y;
if a<b and x>y then n:=a+y;
if a>b and x<y then n:=b+x;
if a>b and x>y then n:=b+x;
writeln(n);
end.
An Error 57 appeared in the second if row between "y" and "<".
Can someone explain why this happened?
A web source indicates that
Error 57is"Then" Expectedand because you did not surround yourIfcomparisons with parenthesis brackets the compiler expects that the next word should be athen. Even if the error is not what the source said you still need to enclose yourIfcomparisons with parenthesis brackets if you have more than one comparison in oneifOtherwise the compiler thinks you want the comparison to be
Which will check if
ais smaller than the result ofb"ANDed" withx