9618/22/M/J/21 question 1: worked solution (May/June 2021, paper 22)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 1 of 3. Q2 9618/22/M/J/21 original Q1 Structured · 11 marks Worked solution (a)(i) Match each example value to its data type: Variable Data type Name STRING Index INTEGER Modified BOOLEAN Holiday DATE Name: STRING [1] Index: INTEGER [1] Modified: BOOLEAN [1] Holiday: DATE [1] (a)(ii) Use Modified = FALSE, Index = 100, Name = "Catherine": Expression Evaluates to Modified OR Index > 100 FALSE LENGTH("Student: " & Name) 18 INT(Index + 2.9) 102 MID(Name, 1, 3) "Cat" FALSE OR (100 > 100) = FALSE OR FALSE = FALSE [1] "Student: " has 9 characters and "Catherine" has 9, so 18 [1] 100 + 2.9 = 102.9, INT removes the decimal part: 102 [1] The first 3 characters: "Cat" (keep the quotation marks and the capital C) [1] (b) Statement Selection Assignment Iteration Index ← Index + 1 ✓ IF Modified = TRUE THEN ✓ ENDWHILE ✓ Index ← Index + 1 is assignment [1] IF ... THEN is selection [1] ENDWHILE ends a loop, so it is iteration [1] KEY IDEA Choose the data type from the kind of value stored, and work through expressions one function at a time. TOTAL 11 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Papersdock. Tap the picture to open it on YouTube.