0
votes

I have a code:

for i:=0 to High(a) do
begin 
    { I want to write 0 and 1 represent for true and false }
    writeln(i % 2 = 0);
end;

But the line with "writeln" occurs error

Syntax error, ")" expected but "ordinal const" found

anyone can help me? :(

Thanks :D

1

1 Answers

1
votes

In Pascal/Delphi, the modulus operator is mod:

writeln(i mod 2 = 0);

% is not a Pascal/Delphi operator at all.

Hence, this has nothing to do with the Writeln procedure not accepting booleans.


This will print FALSE or TRUE. If you want 0 or 1, you need Ord(i mod 2 = 0) or, even nicer, Ord(not Odd(i)).