Past-paper question · 2016 October-November · Paper 23 · Q19(e)(v)

Question 19(e)(v) 2016 · October-November · Paper 23 · 7 marks

Original past-paper question for 19(E)(V)
Original past-paper question for 19(E)(V)
Original past-paper question for 19(E)(V)
Original past-paper question for 19(E)(V)
Original past-paper question for 19(E)(V)
Original past-paper question for 19(E)(V)
Original past-paper question for 19(E)(V)
Original past-paper question for 19(E)(V)
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_23.pdf →

Show text version of question

Question 19

Part (e)

(v)

Question 19

ENDWHILE

Question 7

A
first attempt was made at writing the ‘Search for product code’ module.

Ahmed designs this as a function ProductCodeSearch.

The function returns an integer value as follows:

  • if the product code is found, it returns the index position of the 1D array PCode being
  • searched

  • if the product code is not found, the function returns -1

Write program code for function ProductCodeSearch.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Question 18

5 Study the following pseudocode statements.

CONST Pi = 3.1 : REAL

DECLARE Triangle, Base, Height, Radius, Cone : REAL

DECLARE a, b, c, Answer2 : INTEGER

DECLARE Answer1 : BOOLEAN

Base 2.6

Height 10

Triangle (Base * Height) / 2

Radius 1

Height 2

Cone 2 * Pi * Radius * (Radius + Height)

a 13

b 7

c 3

Answer1 NOT((a + b + c) > 28)

Total 34

Total Total - 2

Answer2 a + c * c

Give the final value assigned to each variable.

(v)

Answer2 ...................................

[1]

Question 19

Appendix Built-in functions (pseudocode)

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("New York", 5) returns 'Y'

CHARACTERCOUNT(ThisString : STRING) RETURNS INTEGER

returns the number of characters in ThisString.

For example: CHARACTERCOUNT("New York") returns 8

SUBSTR(ThisString : STRING, Value1 : INTEGER, Value2 : INTEGER) RETURNS STRING

returns a sub-string from within ThisString. Value1 is the start index position (counting from the left, starting with 1). Value2 is the final index position.

For example: SUBSTR("art nouveau", 5, 11) returns "nouveau"

TONUM(ThisString : STRING) RETURNS INTEGER or REAL

returns the integer or real equivalent of the string ThisString.

For example: TONUM("502") returns the integer 502 TONUM("56.36") returns the real number 56.36

ASC(ThisCharacter : CHAR) RETURNS INTEGER

returns an integer which is the ASCII character code for the character ThisCharacter.

For example: ASC('A') returns integer 65

Question 20

CHR(Value : INTEGER) RETURNS CHAR

returns the character that ASCII code number Value represents.

For example: CHR(65) returns 'A'

RND() RETURNS REAL

returns a random number in the range 0 to 0.99999

For example: RND() returns 0.67351

INT(ThisNumber : REAL) RETURNS INTEGER

returns the integer part of ThisNumber.

For example: INT(12.79) returns 12

Errors

For any function, if the program calls the function incorrectly, the function returns an error.

Concatenation operator

& – Concatenates two expressions of STRING or CHAR data type.

For example: "South" & " " & "Pole" produces "South Pole" 'B' & "000654" produces "B000654"

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 International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series.

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

Topic relevance

Why this question appears here

99% 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_w16_qp_23.pdf

Keep practising this topic