Past-paper question · 2016 October-November · Paper 21 · Q19(b)(iv)

Question 19(b)(iv) 2016 · October-November · Paper 21 · 13 marks

Question 19

Part (b)

(iv)

Question 19

ENDWHILE

Question 7

Identify the following constructs in the given program, using line numbers.

For multi-line constructs give the first line number only.

Construct Line number

Assignment Selection Iteration

[3]

Question 8

3 You will need to refer to the list of pseudocode string-handling functions in the Appendix.

ASCII code table (part)

Character Decimal Character Decimal Character Decimal

<Space> 32 I 73 R 82

A
65 J 74 S 83
B
66 K 75 T 84
C
67 L 76 U 85
D
68 M 77 V 86

E 69 N 78 W 87 F 70 O 79 X 88 G 71 P 80 Y 89 H 72 Q 81 Z 90

Part (a)

For each statement, write the value assigned to the variable.

(iv)

Word SUBSTR("Welcome home", 4, 7) )

Word ............................................................................................................................[1]

Question 9

Question 3(b) continues on page 10.

Question 10

Part (b)

A programmer wants to design a procedure to calculate a customer ID number from the

customer’s surname.

The procedure will:

  • input the surname
  • isolate each character in the surname and find the corresponding ASCII code
  • calculate the total of all these ASCII codes
  • this total is the customer ID

(i)

Complete the pseudocode for this procedure.

You will need to refer to the list of pseudocode string-handling functions in the Appendix.

PROCEDURE CalculateCustomerID

OUTPUT "Key in surname"

INPUT Surname

Length ............................................................................................................

CustomerID 0

FOR i 1 TO Length

// NextChar is a single character from Surname

NextChar ...................................................................................................

NextCodeNumber ASC(NextChar)

CustomerID CustomerID + ...................................................................

ENDFOR

OUTPUT "Customer ID is ", CustomerID

[3]

Question 11

(ii)

Write program code for procedure CalculateCustomerID.

Visual Basic and Pascal: You should include declaration statements for variables. Python: You should show a comment statement for each variable used with its data type.

Programming language .....................................................................................................

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.......................................................................................................................................[6]

Question 12

Reveal official mark-scheme answer

The answer for this question is in the official mark scheme: open the mark scheme.

Mark scheme 9608_w16_ms_21.pdf →

Topic relevance

Why this question appears here

92% assigned-topic match · Programming › Programming basics

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

Keep practising this topic