Past-paper question · 2024 May-June · Paper 23 · Q8(a)

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

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

Official answer for Question 8

Part (a)

✓
Example:

Question 7

✓
FUNCTION Header(Line : STRING) RETURNS STRING
✓
IF LENGTH(Line) >= 13 THEN
✓
IF TO_UPPER(LEFT(Line, 9)) = "FUNCTION " THEN
✓
RETURN "F" & RIGHT(Line, LENGTH(Line) - 9)
✓
ENDIF
✓
IF TO_UPPER(LEFT(Line, 10)) = "PROCEDURE " THEN
✓
RETURN "P" & RIGHT(Line, LENGTH(Line) - 10)
✓
ENDIF
✓
ENDIF
✓
RETURN ""
✓
ENDFUNCTION
✓
Mark as follows:

Question 1

✓
Function heading, parameter, return type and ending

Question 2

✓
Check that the line is at least 13 characters long before attempting to
✓
extract and return empty string

Question 3

✓
Attempt at: Extract characters, 9 or 10 characters, corresponding to
✓
keyword plus space and compare with appropriate keyword plus space

Question 4

✓
Completely correct MP3

Question 5

✓
Use of type case conversion to allow for 'any case'

Question 6

✓
Calculation of 'rest of line' and concatenation with 'P or 'F'

Question 7

✓
Return string
✓
9618/23
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2024
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_s24_ms_23.pdf →

Show text version of question

Question 8

Part (a)

Question 8

A teacher is designing a program to process pseudocode projects written by her students.

The program analyses a student project and extracts information about each module that is defined (each procedure or function). This information is stored in a global 2D array ModInfo of type string.

A
module header is the first line of a module definition and starts with either of the keywords

PROCEDURE or FUNCTION.

An example of part of the array is given below. Row 10 of the array shows that a procedure header occurs on line 27 and row 11 shows that a function header occurs on line 35. "P" represents a

procedure and "F" represents a function:

x = 1 x = 2 x = 3

ModInfo[10, x] "27" "P" "MyProc(Z : CHAR)"

ModInfo[11, x] "35" "F" "MyFun(Y : CHAR) RETURNS BOOLEAN"

The string stored in column 3 is called the module description. This is the module header without the keyword.

A
valid module header will:
  • be at least 13 characters long
  • start with the keyword PROCEDURE or FUNCTION. The keyword may appear in either upper or

lower case (or a mix of both) and must be followed by a space character.

The teacher has defined the first program module as follows:

Module Description Header() • called with a parameter of type string representing a line of pseudocode

  • if the line is a valid procedure header, returns a string:

"P<Module description>"

  • if the line is a valid function header, returns a string:
  • "F<Module description>"

  • otherwise, returns an empty string

For example, given the string:

"FUNCTION Zap(X : INTEGER) RETURNS CHAR"

Header()returns the string:

"FZap(X : INTEGER) RETURNS CHAR"

Question 19

, ,

Part (a)

Write pseudocode for module Header().

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[7]

Question 20

, ,

Topic relevance

Why this question appears here

91% assigned-topic match · Data types and structures › Data types and records

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

Keep practising this topic