Past-paper question · 2016 May-June · Paper 22 · Q1

Question 1 2016 · May-June · Paper 22 · 6 marks

Original past-paper question for 1
Original past-paper question for 1
Reveal official mark-scheme answer Official mark-scheme answer for 1

Official answer for Question 1

[6]
✓
String1
✓
String2
✓
Position
✓
Digit1
✓
Digit2
✓
Sum
✓
Carry
✓
Result
✓
"0"
✓
""

Question 6

✓
"1"
✓
"0"
✓
"1"
✓
"1"

Question 5

✓
"0"
✓
"0"
✓
"0"
✓
"01"

Question 4

✓
"1"
✓
"1"
✓
"0"
✓
"1"
✓
"001"

Question 3

✓
"1"
✓
"1"
✓
"1"
✓
"1001"

Question 2

✓
"1"
✓
"0"
✓
"0"
✓
"01001"

Question 1

✓
"0"
✓
"0"
✓
"1"
✓
"0"
✓
"101001"
✓
1 mark for each of columns 3 to 8.

Mark scheme 9691_s16_ms_22.pdf →

Show text version of question

Question 1

A
high-level programming language has built-in string handling functions specified as follows:

ONECHAR(ThisString : STRING, x : INTEGER) RETURNS STRING

returns a string value consisting of one character from the string ThisString at position x.

For example: ONECHAR("STOP", 4) returns "P"

CONCAT(String1 : STRING, String2 : STRING) RETURNS STRING

returns a string value consisting of String1 followed by String2.

For example: CONCAT("HE", "LLO") returns "HELLO"

Use the pseudocode on the following page to complete the trace table for the function call

Process("011101", "001100")

String1 String2 Position Digit1 Digit2 Sum Carry Result

[6]

Question 3

FUNCTION Process(String1, String2 : STRING) RETURNS STRING Carry ← "0" Result ← "" FOR Position ← 6 DOWN TO 1 Digit1 ← ONECHAR(String1, Position) Digit2 ← ONECHAR(String2, Position) IF Carry = "0" THEN CASE OF Digit1 "0": Sum ← Digit2 "1": CASE OF Digit2 "0": Sum ← "1" "1": Sum ← "0" Carry ← "1" ENDCASE ENDCASE ELSE CASE OF Digit1 "0": CASE OF Digit2 "0": Sum ← "1" Carry ← "0" "1": Sum ← "0" ENDCASE "1": CASE OF Digit2 "0": Sum ← "0" "1": Sum ← "1" ENDCASE ENDCASE ENDIF Result ← CONCAT(Sum, Result) ENDFOR RETURN Result ENDFUNCTION

Question 4

Topic relevance

Why this question appears here

82% 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 9691_s16_qp_22.pdf

Keep practising this topic