The Basic Types
Pascal has four basic types you'll use constantly: integer (whole numbers), real (decimals), string (text), and boolean (true/false).
var
age: integer;
gpa: real;
name: string;
passed: boolean;
begin
age := 20;
gpa := 4.5;
name := 'Ada';
passed := true;
end.
Arithmetic operators
writeln(7 + 3); { 10 }
writeln(7 - 3); { 4 }
writeln(7 * 3); { 21 }
writeln(7 / 3); { always a real, even for whole numbers }
writeln(7 div 3); { 2 -- div is integer division }
writeln(7 mod 3); { 1 -- mod is the remainder }
Comparison and logical operators
writeln(5 = 5); { TRUE }
writeln(5 <> 3); { TRUE }
writeln((5 > 3) and (2 < 4)); { TRUE }
writeln((5 > 3) or (2 > 4)); { TRUE }
writeln(not true); { FALSE }
Why This Matters for Your Exams
/ vs div is the single most common source of "wrong type" bugs -- / always produces a real, even for two whole numbers, while div truncates to an integer. Mixing them up where an integer is required fails to compile.
Try it yourself
lock
Real-time practice is a paid add-on
Reading units and the practice quiz are free. Pay once to unlock running real code for PASCAL.

