Past-paper question · 2014 October-November · Paper 23 · Q1(b)(i)

Question 1(b)(i) 2014 · October-November · Paper 23 · 4 marks

Original past-paper question for 1(B)(I)
Original past-paper question for 1(B)(I)
Reveal official mark-scheme answer Official mark-scheme answer for 1(B)(I)

Official answer for Question 1

Part (b)

(i)

Part (b)

(i)

PROCEDURE InitialiseArrayCounts

✓
DECLARE i : INTEGER
✓
FOR i 1 TO 4
✓
Tally[i] 0
✓
ENDFOR
✓
ENDPROCEDURE
✓
1 mark for declaration/local variable
✓
1 mark for loop 1 to 4
✓
1 mark for array element set to 0
✓
PROCEDURE InputStudentChoices
✓
REPEAT
✓
INPUT Choice
✓
Tally[Choice] Tally[Choice] + 1
✓
UNTIL Choice = 0
✓
ENDPROCEDURE
✓
1 mark for replacing CASE statement with single array element assignment
[4]

Mark scheme 9691_w14_ms_23.pdf →

Show text version of question

Question 1

Part (b)

(i)

Question 1

Rema surveys the students in her class to find out which is the most popular sport.

She draws a tally chart:

1 Cricket \\\\\\\\

2 Football \\

3 Tennis \\\

4 Swimming \\\\\\

Rema plans to collect sport data from students in the whole school. She designs a program to:

  • input the number of the sport a student likes best (1, 2, 3 or 4)
  • repeatedly ask for input until the input is 0 (zero)
  • keep a count of each choice
  • on completion of data entry, print out the results as a tally chart (as shown above)

Rema’s first attempt is the following pseudocode:

Cricket ← 0 Football ← 0 Tennis ← 0 Swimming ← 0 REPEAT INPUT Choice CASE Choice OF 1: Cricket ← Cricket + 1 2: Football ← Football + 1 3: Tennis ← Tennis + 1 4: Swimming ← Swimming + 1 ENDCASE UNTIL Choice = 0 OUTPUT "Cricket ", Cricket OUTPUT "Football ", Football OUTPUT "Tennis ", Tennis OUTPUT "Swimming ", Swimming

Her friend Aisha suggests that the pseudocode could be improved by:

  • using a one-dimensional array, Tally, instead of four variables to store the counts
  • modularising the design.

The main program should just consist of three procedure calls: InitialiseArrayCounts InputStudentChoices OutputTallyChart

(i)

Write the pseudocode for the procedures InitialiseArrayCounts and

InputStudentChoices:

PROCEDURE InitialiseArrayCounts

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

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

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

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

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

ENDPROCEDURE

PROCEDURE InputStudentChoices

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

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

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

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

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

ENDPROCEDURE

[4]
Topic relevance

Why this question appears here

91% assigned-topic match · Programming › Programming basics

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 9691_w14_qp_23.pdf

Keep practising this topic