Examo
PracticeAbout
Homecomputer-scienceProgramming Concepts
0984

Programming Concepts

Programming · 4 question types

Practise
Download PDF

0984 Topics

Programming Concepts13%
  1. Variables, Constants and Data Types
  2. Arithmetic Operators
  3. Comparison (Relational) Operators
  4. Logical (Boolean) Operators
  5. String Operations
  6. A Reference Card
Arrays5%
File Handling3%
Procedures and Functions4%

Frequency legend

High (≥14%)
Above avg (10 to 13%)
Average (<10%)

Exam Frequency Analysis

Past paper frequency (2018 to 2024)

This topic accounts for approximately 13% of your exam marks.

stable
High
Stable13%

Paper 2 is almost entirely programming. Variable types, assignments, loops and conditionals are tested every session.

Every program manipulates data: numbers, text, true/false values. To work with data, the program stores values in named variables (which can change) and constants (which cannot).

Variables

A variable is a named storage location whose value can change while the program is running.

In CIE pseudocode, a variable is declared with DECLARE and a data type:

DECLARE Age : INTEGER
DECLARE Price : REAL
DECLARE Name : STRING
DECLARE FirstInitial : CHAR
DECLARE GameOver : BOOLEAN

After declaration, a value is assigned with the arrow operator ←:

Age ← 17
Price ← 9.99
Name ← "Alice"
FirstInitial ← 'A'
GameOver ← FALSE

Constants

A constant is a named storage location whose value is set once and cannot change for the rest of the program.

CONSTANT PI ← 3.142
CONSTANT VAT ← 0.20
CONSTANT MAX_LIVES ← 3

Constants are usually written in UPPERCASE so they stand out from variables, and they make programs easier to maintain: if VAT changes, only one line of the program has to be edited.

Naming conventions

Identifiers (the names of variables and constants) should:

  • Use letters and digits only, no spaces.
  • Start with a letter, not a digit.
  • Be in PascalCase (each word capitalised, e.g. TotalScore) or camelCase.
  • Be descriptive: StudentScore is far better than s or x.
  • For constants, prefer ALL_CAPS with underscores.

Data types

Cambridge IGCSE recognises five basic data types. Choosing the right one for each variable makes the program more accurate and uses memory efficiently.

Data typeUsed forPseudocode keywordExamples
IntegerWhole numbers (no fractional part)INTEGER10, -5, 0, 1000
RealNumbers with a fractional partREAL3.14, -2.5, 0.0
CharA single characterCHAR'a', 'B', '7', '£'
StringA sequence of charactersSTRING"Hello world", "ABC", ""
BooleanA logical valueBOOLEANTRUE, FALSE

Notes on the difference between char and string:

  • A CHAR is exactly one character, written in single quotes ('A').
  • A STRING is zero or more characters, written in double quotes ("Apple").

Casting

Sometimes a value needs to be converted from one type to another. This is called casting. For example, a number typed by the user arrives as a STRING and may need to be converted to an INTEGER before arithmetic can be done on it.

Common slip: trying to add "5" to "3" as strings gives "53" (concatenation), not 8. Cast to integer first.

Picking the right data type

Example — Choose the most appropriate data type for each piece of data, using a different type for each.

DataBest data typeWhy
83IntegerA whole number
myemail@example.comStringA sequence of characters
TRUEBooleanA logical value
'M'CharA single character (e.g. gender code)
3.14RealA number with a fractional part

Previous

Tying Searching and Sorting Together

Next

Arithmetic Operators