HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to PascalVariablesData Types & ConversionOperatorsStringsConditions (if)Loops (for / while)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
✍️ String
🔁 Condition & Loop
🧩 Function & Procedure
Pascal›Introduction to Pascal

Introduction to Pascal

The first step into Pascal, the educational classic of structured programming: program structure and writeln.

Simple enough for a 5-year-old to understand

The structure of a Pascal program

The program starts with "program name;" and runs between "begin ... end." (ending with a period).

Your first program
1
program Hello;
Program name.
DefinitionProgram name.
2
begin
Main block.
DefinitionMain block.
3
writeln('Hello!');
Writer (text SINGLE quotes).
Output / InputWriter (text SINGLE quotes).
4
end.
End of program — with a PERIOD.
DefinitionEnd of program — with a PERIOD.
DefinitionOutput / Input
💡 Hint: Texts in single quotes: 'Hello'. The program ends with end. (period).

🎯 Exercise & Practice

Test what you've learned — answer, write code, check instantly. (1 left)

1.Print exactly Hello World to the screen.

🎯 Expected output: Hello World

Loading editor…

About this topic

Pascal was designed in 1970 by Niklaus Wirth to teach programming. Its goal was to embed structured programming principles directly into the syntax of the language: the beginning and end of every block are clear, every variable is declared, and every type is explicit.

This discipline made Pascal an educational language for decades. Today, it is still used in computer science classes and olympiad preparations in many countries; thanks to Free Pascal and Lazarus, it also runs on modern systems.

Pascal's syntax prioritizes readability. Words are used instead of curly braces, and assignment versus comparison are written with different signs. While these details might seem like extra writing at first, they leave no ambiguity about intent.

What you will learn

  • Program structure and blocks
  • Printing to the screen with writeln
  • The role of the semicolon
  • That the program ends with a dot
  • Writing comment lines

Who is this for?

  • Students who are new to programming
  • Those preparing for algorithms and olympiads
  • Maintainers of legacy Pascal code

When to use?

Pascal is still very well suited for teaching structured programming concepts and practicing algorithms; the language forces you to write with discipline.

It is not preferred for new commercial projects; the library ecosystem is narrow and the community is small.

Common mistakes

Wrong

program Merhaba;
begin
  writeln('Hello');
end

A dot must come after the final end keyword of the program; writing a semicolon or nothing at all produces a compiler error. The dot signals that the source file is finished and is a rule specific to Pascal.

Correct

program Merhaba;
begin
  writeln('Hello');
end.

Wrong

program Merhaba;
begin
  write('one');
  write('two');
end.

There is no error here, but the output is different than expected: "onetwo" is printed to the screen because write does not add a newline. The version that wants a newline is written with the ln suffix at the end. The only difference between the two is this, and it is frequently confused.

Correct

program Merhaba;
begin
  writeln('one');
  writeln('two');
end.

Wrong

program Merhaba;
begin
  writeln("Hello");
end.

In Pascal, strings are written exclusively with single quotes; double quotes are not a valid string marker and will produce a syntax error. If you need a single quote inside the text, you escape it by writing it twice.

Correct

program Merhaba;
begin
  writeln('Hello');
end.

Frequently asked questions

Is Pascal case-sensitive?

No. Letter casing does not matter for variables and keywords; two different formats you write refer to the same name. However, adopting a consistent spelling style is important for readability.

Where do you put the semicolon?

In Pascal, the semicolon separates statements, it does not terminate them. Therefore, it is not mandatory after the last statement in a block, and writing it in certain places produces an error — especially right before else.

Which Pascal compiler should I use?

Free Pascal is the most common and up-to-date option today; it runs on Windows, Linux, and macOS. If you want to develop graphical interfaces, Lazarus provides an environment using the same compiler.

Summary

The program ends with a dot.

writeln adds a newline, write does not.

Strings are written with single quotes.

The language is not case-sensitive.

Semicolons separate statements.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code