Question bank › GCSE Computer Science › Programming

Programming concepts: sequence, selection, iteration & Boolean/relational operators

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

1Grade 4–54 marks

This algorithm calculates the price of a ticket.

age ← STRING_TO_INT(USERINPUT)
IF age < 5 THEN
   price ← 0
ELSE IF age < 16 THEN
   price ← 4
ELSE IF age ≥ 65 THEN
   price ← 5
ELSE
   price ← 9
ENDIF
OUTPUT price

State the output when the user enters:

(a) 3 [1]
(b) 16 [1]
(c) 70 [1]
(d) 15 [1]

2Grade 4–54 marks

Look at this algorithm.

scores ← [12, 5, 18, 7, 10]
total ← 0
count ← 0
FOR i ← 0 TO LEN(scores) - 1
   IF scores[i] ≥ 10 THEN
      total ← total + scores[i]
      count ← count + 1
   ENDIF
ENDFOR
OUTPUT total
OUTPUT count

(a) State the two values output by the algorithm. [2]

(b) Explain why a FOR loop has been used rather than a WHILE loop. [1]

(c) Write one line of AQA pseudocode, to be added at the end of the algorithm, that outputs the mean of the scores that were added to total. Your line must not use any fixed numbers, so that it would still give the correct mean if the values in scores were changed. You may assume at least one score is 10 or more. [1]

Still losing marks on this topic?

Book a free introductory session and we'll find exactly which step is costing you.

Book a free intro