Past-paper question · 2019 October-November · Paper 22 · Q3(b)

Question 3(b) 2019 · October-November · Paper 22 · 8 marks

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

Official answer for Question 3

Part (b)

✓
DECLARE Index : INTEGER

Question 8

✓
DECLARE NextChar : CHAR
✓
DECLARE NextCharValue : INTEGER
✓
FOR Index ← 1 TO LENGTH(InString)
✓
NextChar ← MID(InString, Index, 1)
✓
NextCharValue ← STRING_TO_NUM(NextChar)
✓
Result[NextCharValue] ← Result[NextCharValue] + 1
✓
ENDFOR
✓
FOR Index ← 0 TO 9
✓
OUTPUT "Count of digit " & NUM_TO_STRING(Index) & " : "
✓
& NUM_TO_STRING(Result[Index])
✓
ENDFOR
✓
One mark for each of the following:
✓
1.
✓
Declaration of INTEGER variable for Index (or equivalent) to index
✓
Result array
✓
2.
✓
First loop from 1 to length of InString:
✓
3.
✓
Select each character (e.g MID) in first loop
✓
4.
✓
Apply type conversion to obtain integer value for index in first loop
✓
5.
✓
Increment element of Result array in a loop
✓
6.
✓
Separate second loop to repeat 10 times:
✓
7.
✓
Attempt to OUTPUT two items (digit 0 to 9 plus corresponding count) in
✓
any loop
✓
8.
✓
OUTPUT statement including index and count in any loop including type
✓
conversion of element from array if required in a loop
✓
9608/22
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November
✓
PUBLISHED
✓
2019
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w19_ms_22.pdf →

Show text version of question

Question 3

Part (b)

Question 3

A student is developing a program to search through a string of numeric digits to count how many

times each digit occurs. The variable InString will store the string and the 1D array Result will store the count values.

The program will:

  • check each character in the string to count how many times each digit occurs
  • record the count for each digit using the array
  • output the count for each element of the array together with the corresponding digit.

Part (b)

Write the pseudocode for the program.

Declare any variables you use. Do not implement the code as a subroutine.

Refer to the Appendix on page 18 for the list of built-in functions and operators.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[8]

Question 8

Topic relevance

Why this question appears here

71% assigned-topic match · Hardware › Logic gates and logic circuits

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_w19_qp_22.pdf

Keep practising this topic