Past-paper question · 2019 May-June · Paper 21 · Q3(a)

Question 3(a) 2019 · May-June · Paper 21 · 7 marks

Original past-paper question for 3(A)
Reveal official mark-scheme answer Official mark-scheme answer for 3(A)

Official answer for Question 3

Part (a)

✓
TotalValue ← 0

Question 7

✓
ZeroCount ← 0
✓
FOR Index ← 1 TO 100
✓
TotalValue ← TotalValue + Result[Index]
✓
IF Result[Index] = 0.0
✓
THEN
✓
ZeroCount ← ZeroCount + 1
✓
ENDIF
✓
ENDFOR
✓
OUTPUT "The average is ", (TotalValue / 100)
✓
OUTPUT "The number of elements with a zero value is ",
✓
ZeroCount
✓
One mark for each of the following:

Question 1

✓
Both initialisations

Question 2

✓
Loop 100 times

Question 3

✓
Adding individual element to TotalValue in a loop

Question 4

✓
Check if element value is zero in a loop

Question 5

✓
If so increment ZeroCount in a loop

Question 6

✓
Average is calculated after the loop

Question 7

✓
Both OUTPUT statements, including message and variables

Mark scheme 9608_s19_ms_21.pdf →

Show text version of question

Question 3

Part (a)

A
student is developing an algorithm to search through a 1D array of 100 elements. Each

element of the array, Result, contains a REAL value.

The algorithm will output:

  • the average value of all the elements
  • the number of elements with a value of zero.

The structured English description of the algorithm is:

1. SET Total value to 0 2. SET Zero count to 0 3. SELECT the first element 4. ADD value of element to Total value 5. IF element value is 0 then INCREMENT Zero count 6. REPEAT from step 4 for next element, until element is last element 7. SET Average to Total / 100 8. OUTPUT a suitable message and Average 9. OUTPUT a suitable message and Zero count

Write pseudocode for this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................

[7]

Question 6

Topic relevance

Why this question appears here

82% assigned-topic match · Programming › Constructs

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_s19_qp_21.pdf

Keep practising this topic