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

Variables

var, := and const.

CommandDescription
var / :=Variable declaration and assignment.
constImmutable constant.

var / :=

Try it yourself →

Variable declaration and assignment.

Syntax

var name: Type;  ...  name := value;

Description

Variables are declared in the var block BEFORE begin. Assignment uses :=. Types: integer, real, string, boolean, char.

Example

program H;
var
  age: integer;
  name: string;
begin
  age := 36;
  name := 'Alex';
  writeln(name, ' ', age);
end.

Expected output

Alex 36

When to use?

Storing all kinds of data.

Common mistakes

  • ⚠️ Assignment uses :=, not =. = is for comparison only.

const

Try it yourself →

Immutable constant.

Syntax

const NAME = value;

Description

Values defined in the const block cannot be changed.

Example

program H;
const
  PI = 3.14;
begin
  writeln(PI);
end.

Expected output

3.14

When to use?

Constant values.

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