IGCSE · Practice questions · Variables, constants and data types

Store it right.

Six original Cambridge-style questions on variables, constants, data types and sequence, with mark points.

Original questions All questions on this page are original work, written in the Cambridge IGCSE style. They are not from past papers. They test the same concepts and skills the syllabus rewards.
Keep these straight

Name, type, value.

01
Explain
[2 marks]

Explain the difference between a variable and a constant.

  • A variable is a named memory location whose value can change while the program is running. ✓
  • A constant is a named value that cannot be changed while the program is running. ✓
02
Apply
[5 marks]

A school stores these items for each student. Give the most suitable data type for each: (a) StudentName (b) Age (c) AverageMark, e.g. 67.5 (d) HasPaidTrip (e) FormLetter, e.g. 'C'.

  • (a) STRING ✓
  • (b) INTEGER ✓
  • (c) REAL ✓
  • (d) BOOLEAN ✓
  • (e) CHAR ✓
03
Write
[4 marks]

Write pseudocode that declares a constant Pi with the value 3.142, inputs the radius of a circle, then calculates and outputs the area (Pi × radius2).

  • CONSTANT Pi ← 3.142 ✓
  • DECLARE Radius : REAL and DECLARE Area : REAL ✓
  • INPUT Radius ✓
  • Area ← Pi * Radius ^ 2 then OUTPUT Area (or OUTPUT with a message) ✓
04
Trace
[3 marks]

State the output of this pseudocode.

A ← 4
B ← 3
C ← A * B - 2
A ← C + A
B ← A - B
OUTPUT A, " ", B, " ", C
  • C ← 4 * 3 - 2 = 10. ✓
  • A ← 10 + 4 = 14; B ← 14 - 3 = 11. ✓
  • Output: 14 11 10 ✓
05
Explain
[2 marks]

A programmer stores mobile phone numbers as INTEGER. Explain why STRING would be a better choice.

  • A number stored as an integer would lose its leading zero (and could not hold spaces or a + sign). ✓
  • No arithmetic is ever done on a phone number, so it does not need a numeric type. ✓
06
Analysis
[3 marks]

A student chooses the identifiers 2ndScore, Total Mark and OUTPUT. Explain why each one is not allowed.

  • 2ndScore starts with a digit; an identifier must start with a letter. ✓
  • Total Mark contains a space; identifiers contain only letters and digits. ✓
  • OUTPUT is a keyword, and keywords must never be used as identifiers. ✓

Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.