Question bank › A-level Computer Science › Fundamentals of programming

Data types, operations and programming constructs

Answer on paper first, then reveal the mark scheme one mark at a time.

1Standard4 marks

The algorithm below is written in pseudo-code.

n ← 2026
total ← 0
WHILE n > 0
   total ← total + (n MOD 10)
   n ← n DIV 10
ENDWHILE
OUTPUT total

(a) Complete a trace table, with columns n and total, for the algorithm. Show the initial values in the first row. [3]

(b) State the purpose of the algorithm. [1]

2Standard6 marks

Write a program that:

  • repeatedly asks the user to enter a password until the password entered is valid
  • a valid password has at least 8 characters and contains at least one digit (0–9)
  • displays a suitable message each time an invalid password is entered
  • once a valid password has been entered, displays the number of attempts the user took.

You may write your answer in pseudo-code or a programming language you have studied. [6]

Stuck on this topic?

Book a free 30-minute session on WhatsApp and we'll find exactly which step is costing you the marks. Or build a timed paper on it.

Free 30-minute session