Past-paper question · 2021 May-June · Paper 23 · Q7(a)

Question 7(a) 2021 · May-June · Paper 23 · 7 marks

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

Official answer for Question 7

Part (a)

Question 7

✓
FUNCTION GetStart (WordNum : INTEGER) RETURNS INTEGER
✓
DECLARE Index, ThisPos, NumFound : INTEGER
✓
DECLARE ThisChar : Char
✓
CONSTANT SPACECHAR = ' '
✓
Index ← -1
✓
Numfound ← 0
✓
ThisPos ← 1
✓
IF WordNum = 1 THEN // if looking for word 1...
✓
Index ← 1
✓
// Word 1 always starts at index
✓
// position 1
✓
ELSE
✓
// Otherwise start counting spaces...
✓
WHILE ThisPos <= LENGTH(FNString) AND Index = -1
✓
ThisChar ← MID(FNString, ThisPos, 1)
✓
IF ThisChar = SPACECHAR THEN
✓
NumFound ← NumFound + 1
✓
IF NumFound = WordNum - 1 THEN
✓
Index ← ThisPos + 1 // the start of the
✓
// required word
✓
ENDIF
✓
ENDIF
✓
ThisPos ← ThisPos + 1
✓
ENDWHILE
✓
ENDIF
✓
RETURN Index
✓
ENDFUNCTION

Mark scheme 9618_s21_ms_23.pdf →

Show text version of question

Question 7

Part (a)

Question 7

A program is needed to take a string containing a full name and produce a new string of initials.

Some words in the full name will be ignored. For example, "the", "and", "of", "for" and "to" may all be ignored.

Each letter of the abbreviated string must be upper case.

For example:

Full name Initials

Integrated Development Environment IDE

The American Standard Code for Information Interchange ASCII

The programmer has decided to use a global variable FNString of type STRING to store the full name.

It is assumed that:

  • words in the full name string are separated by a single space character
  • space characters will not occur at the beginning or the end of the full name string
  • the full name string contains at least one word.

The programmer has started to define program modules as follows:

Module Description

  • Called with an INTEGER as a parameter, representing the number of a
  • word in FNString. GetStart()

  • Returns the character start position of that word in FNString or
  • returns –1 if that word does not exist

  • For example: if FNString contains the string "hot and cold",
  • GetStart(3) returns 9

  • Called with a parameter representing the position of the first character
  • of a word in FNString GetWord() • Returns the word from FNString

  • For example: if FNString contains the string "hot and cold",

GetWord(9) returns "cold"

Question 19

Part (a)

Write pseudocode for the module GetStart().

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Question 20

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

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

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

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

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

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

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

[7]
Topic relevance

Why this question appears here

91% 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 9618_s21_qp_23.pdf

Keep practising this topic