Printing and Variables
Pascal programs are built from a program header, a var section for declarations, and a begin...end. block -- every statement ends with a semicolon.
Your first program
program HelloWorld;
begin
writeln('Hello, world!');
end.
Variables
Every variable's type must be declared up front, in a var section, before it's used:
var
name: string;
age: integer;
gpa: real;
Assigning values
begin
name := 'Ada';
age := 20;
gpa := 4.5;
end.
:= is the assignment operator -- = on its own is only for comparisons.
Getting input
var
name: string;
begin
write('What is your name? ');
readln(name);
writeln('Hello, ', name);
end.
Comments
{ This is a comment -- Pascal ignores everything between the braces }
// This is also a comment, to the end of the line
Why This Matters for Your Exams
Pascal is strongly, statically typed -- unlike Python, every variable's type is fixed the moment it's declared and checked before the program even runs. Forgetting a semicolon or mismatching a type is the single most common beginner compile error.
Try it yourself
Change the name below and press Run to see Pascal's own output.
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.

