Past-paper question · 2019 October-November · Paper 21 · Q4(b)

Question 4(b) 2019 · October-November · Paper 21 · 7 marks

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

Official answer for Question 4

Part (b)

✓
DECLARE Index : INTEGER

Question 7

✓
DECLARE Count : INTEGER
✓
FOR Count ← 1 TO LENGTH(InString)
✓
NextChar ← UCASE(MID(InString, Count, 1))
✓
IF NextChar >= 'A' AND NextChar <= 'Z'
✓
THEN
✓
Index ← ASC(NextChar) – 64
✓
Result[Index] ← Result[Index] + 1
✓
ENDIF
✓
ENDFOR
✓
FOR Index ← 1 TO 26
✓
OUTPUT "Letter " & CHR(Index + 64) & " : "
✓
& NUM_TO_STRING(Result[Index])
✓
ENDFOR
✓
One mark for each of the following (max 7):

Mark scheme 9608_w19_ms_21.pdf →

Show text version of question

Question 4

Part (b)

Question 4

A student is developing a program to count how many times each character of the alphabet (A to Z)

occurs in a given string. Upper case and lower case characters will be counted as the same. The string may contain non-alphabetic characters, which should be ignored.

The program will:

  • check each character in the string to count how many times each alphabetic character occurs
  • store the count for each alphabetic character in a 1D array
  • output each count together with the corresponding character.

Part (b)

Write pseudocode to implement the program.

You should note the following:

  • InString contains the string to be checked. It has been assigned a value.
  • The elements of the array Result have all been initialised to zero.
  • The ASCII value of letter ‘A’ is 65.

You should assume the following lines of pseudocode have been written:

DECLARE InString : STRING DECLARE Result : ARRAY [1:26] OF INTEGER

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

Refer to the Appendix on pages 16–17 for the list of built-in functions and operators.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[7]

Question 10

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

Keep practising this topic