Question 1 2016 · May-June · Paper 22 · 6 marks
Reveal official mark-scheme answer
Official answer for Question 1
Question 6
Question 5
Question 4
Question 3
Question 2
Question 1
Show text version of question
Question 1
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
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
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
