2210/22/O/N/23 question 4: worked solution (October/November 2023, paper 22)
Show as plain textHide plain text
Cambridge O Level Computer Science 2210 · 8.2 Arrays Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 3. Q51 2210/22/O/N/23 original Q4 Structured · 9 marks Worked solution (a) Read the algorithm line by line. Lines 01 and 05 share one mark, so they can earn only one mark between them. Any four marks score: Line 05: IF is wrong. A loop is needed, so write REPEAT [1] (or give the line 01 correction below instead, for the same mark) Line 07: the city goes in column 1, so write INPUT City[Count, 1] [1] Line 11: the loop stops too early. Write UNTIL Count > 50 (or UNTIL Count = 51) [1] Line 12: the output loop only runs once. Write FOR Out ← 1 TO 50 [1] Line 01: should be DECLARE City : ARRAY[1:50, 1:2] OF STRING (names are text, not BOOLEAN, and a colon is needed after City). This scores in place of line 05, not as well as it. (b) Write any five of these changes: Add an input (with a prompt) asking for the country to search for [1] Store it in a new variable , placed between lines 11 and 12 [1] Inside the output FOR loop add an IF statement, between lines 12 and 13 [1] The IF checks if the country in the current array element (City[Out, 2]) matches the country entered [1] The output in line 13 only happens THEN (when it matches); if it does not match, move on and check the next element [1] If the country does not match, the program moves on and checks the next element [1] KEY IDEA Check each line for the right data type, loop keyword, array column and loop limit; to search, add an input and an IF inside the output loop. TOTAL 9 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Paper solver.. Tap the picture to open it on YouTube.