Past-paper question · 2015 October-November · Paper 22 · Q6(b)(i)

Question 6(b)(i) 2015 · October-November · Paper 22 · 4 marks

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

Official answer for Question 6

Part (b)

(i)

Part (b)

(i)

✓
Identifier
✓
Data Type
✓
Description
✓
InputString
✓
STRING
✓
The string value input by the user
✓
Loop counter // (index) position of
✓
i
✓
INTEGER
[1]
✓
an individual character
✓
Number of characters in / length of
✓
j
✓
INTEGER
[1]
✓
InputString
✓
(Single) character within
✓
NextChar
✓
CHAR//CHARACTER
✓
InputString / from string input
[1]
✓
by the user
✓
The string
✓
NewString
✓
STRING
✓
formed/made/created//output
[1]
✓
Note: Correct (identifier + the data type + description) needed to score
✓
Mark Scheme
✓
Syllabus
✓
Paper
✓
Cambridge International AS/A Level – October/November 2015
✓
9608

Question 22

Mark scheme 9608_w15_ms_22.pdf →

Show text version of question

Question 6

Part (b)

(i)

Question 6

Some pseudocode statements follow which use the following built-in functions:

ONECHAR(ThisString : STRING, Position : INTEGER) RETURNS CHAR returns the single character at position Position (counting from the start of the string with value 1) from the string ThisString. For example: ONECHAR("Barcelona", 3) returns 'r'.

CHARACTERCOUNT(ThisString : STRING) RETURNS INTEGER returns the number of characters in the string ThisString. For example: CHARACTERCOUNT("South Africa") returns 12.

A
program is to be written as follows:
  • the user enters a string
  • the program will form a new string with all <Space> characters removed
  • the new string is output

NewString ""← INPUT InputString

j ← CHARACTERCOUNT(InputString) FOR i ← 1 TO j NextChar ← ONECHAR(InputString, i) IF NextChar <> " " THEN // the & character joins together two strings NewString ← NewString & NextChar ENDIF ENDFOR

OUTPUT NewString

(i)

Complete the identifier table below.

Identifier Data type Description

InputString STRING The string value input by the user

[4]

Question 14

Topic relevance

Why this question appears here

82% 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 9608_w15_qp_22.pdf

Keep practising this topic