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

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

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

Official answer for Question 7

Part (c)

Question 5

✓
FUNCTION GetWord (Index : INTEGER) RETURNS STRING
✓
DECLARE
✓
NextWord : STRING
✓
DECLARE
✓
Done : BOOLEAN
✓
DECLARE
✓
ThisChar : CHAR
✓
DECLARE
✓
Index : INTEGER
✓
CONSTANT SPACECHAR = ' '
✓
NextWord ← ""
✓
Done ← FALSE
✓
REPEAT
✓
ThisChar ← MID(FNString, Index, 1)
✓
IF ThisChar <> SPACECHAR THEN
✓
NextWord ← NextWord & ThisChar // build up NextWord
✓
ENDIF
✓
IF ThisChar = SPACECHAR OR Index = LENGTH(FNString) THEN
✓
Done ← TRUE
✓
ENDIF
✓
Index ← Index + 1
✓
UNTIL Done = TRUE
✓
RETURN NextWord
✓
ENDFUNCTION

Mark scheme 9618_s21_ms_23.pdf →

Show text version of question

Question 7

Part (c)

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 (c)

As a reminder, the module description of GetWord() is repeated:

Module Description

  • 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"

Write pseudocode for the module GetWord().

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[5]

Question 22

Question 23

Question 24

reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cambridgeinternational.org after the live examination series.

Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.

Topic relevance

Why this question appears here

71% 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