Reading — step 1 of 5
Learn
~1 min readControl Flow
if/then/else — note: NO semicolon before else:
if age >= 18 then
WriteLn('adult')
else
WriteLn('minor');
Multiple statements need a begin/end block:
if x > 0 then
begin
WriteLn('positive');
WriteLn('and non-zero');
end
else
WriteLn('zero or negative');
case statement — like switch, more flexible:
case day of
1, 2, 3, 4, 5: WriteLn('weekday');
6, 7: WriteLn('weekend');
else
WriteLn('invalid');
end;
Case labels can be ranges: 1..9: ...
Logical operators: and, or, not (NOT &&, ||, !).
Comparison: =, <> (not equal), <, >, <=, >=.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…