Theory Notes/💻 Topic 1: Solution Development/10.1.6
10.1.6Grade 10

Introduction to Solution Development (Delphi Basics)

Your first real Delphi programs: declaring variables, reading input, doing arithmetic, and displaying formatted output. Everything later in the curriculum sits on top of these.

A console program has a fixed shape: a program header, an optional uses clause, a var block declaring every variable up front, then the statements between begin and end. Note the full stop after the final end.

Example

program Main; {$MODE DELPHI} uses SysUtils; var name: String; age: Integer; average: Real; begin WriteLn('What is your name?'); ReadLn(name); WriteLn('Enter your age:'); ReadLn(age); average := age / 2; WriteLn('Hi ', name, ', half your age is ', average:0:1); end.

TypeHoldsExample
IntegerWhole numbersage := 17;
RealNumbers with decimalsprice := 149.99;
StringText of any lengthname := 'Thandi';
CharExactly one charactergrade := 'A';
BooleanTrue or Falsepassed := True;
:= (assignment)
Puts a value into a variable. A single = is the equality COMPARISON — mixing them up is the most common beginner error in Pascal.
div and mod
Whole-number division and remainder. 47 div 5 = 9, 47 mod 5 = 2. Plain / always produces a Real.
Formatting
value:width:decimals. WriteLn(x:0:2) prints two decimals; without it a Real prints in scientific notation.

💡 Exam Tip

Forgetting the :0:2 on a Real is the single most common reason a correct calculation is marked wrong — the memo expects 9.40, not 9.4000000000E+00.