IGCSE · Practice questions · Writing maintainable programs

Make it readable.

Six original Cambridge-style questions on writing maintainable programs, 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, explain, reuse.

01
Recall
[3 marks]

Identify three ways a programmer can make a program easier to maintain.

  • Use meaningful identifiers (for variables, constants, arrays, procedures and functions). ✓
  • Add comments explaining the purpose of the code. ✓
  • Use procedures and functions (or constants, or consistent indentation). ✓
02
Explain
[2 marks]

Explain why programmers use meaningful identifiers.

  • The name shows what data the variable stores or what the subroutine does. ✓
  • So other programmers (or the same programmer later) can understand, debug and update the code more easily. ✓
03
Apply
[4 marks]

Rewrite this pseudocode to make it more maintainable.

A ← 0
FOR B ← 1 TO 7
    INPUT C
    A ← A + C
NEXT B
OUTPUT A / 7
  • A comment explaining the purpose, e.g. // average daily temperature for one week. ✓
  • A constant, e.g. CONSTANT DaysInWeek ← 7, used in the loop and the division. ✓
  • Meaningful identifiers, e.g. Total, Day, Temperature. ✓
  • Declarations with suitable data types, e.g. DECLARE Temperature : REAL. ✓
04
Explain
[2 marks]

Explain the purpose of comments in a program.

  • Comments explain what sections of code do (or why). ✓
  • They are ignored by the computer but help programmers understand and maintain the code. ✓
05
Analysis
[3 marks]

Explain why each identifier is unsuitable: (a) Average Mark (b) Q for the number of questions answered (c) Total_Cost

  • (a) It contains a space, which is not allowed in an identifier. ✓
  • (b) A single letter is not meaningful; it does not say what is stored (e.g. use QuestionsAnswered). ✓
  • (c) Underscores are not used in 0478 identifiers; use TotalCost. ✓
06
Explain
[2 marks]

A program uses the value 15 in several places as the maximum number of players. Explain the benefit of declaring it as a constant.

  • The value is given a meaningful name (e.g. MaxPlayers), so the code is easier to read. ✓
  • If the maximum changes, it is updated in one place, and it cannot be changed accidentally while the program runs. ✓

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.