Reputation: 1
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?
Upvotes: 0
Views: 141
Reputation: 1607
A web source indicates that Error 57
is "Then" Expected
and because you did not surround your If
comparisons with parenthesis brackets the compiler expects that the next word should be a then
. Even if the error is not what the source said you still need to enclose your If
comparisons with parenthesis brackets if you have more than one comparison in one if
if (a<b) and (x<y) then n:=a+y;
Otherwise the compiler thinks you want the comparison to be
a < b and x
Which will check if a
is smaller than the result of b
"ANDed" with x
Upvotes: 1