2210/21/M/J/22 question 5: worked solution (May/June 2022, paper 21)

Show as plain text

Cambridge O Level Computer Science 2210 · 7.7 Trace tables Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8. Q51 2210/21/M/J/22 original Q5 Structured · 7 marks Worked solution (a) Limit is the first input (8), so the loop runs 8 times, reading Value each time. Only 3-digit values are looked at. First is the first digit (Value DIV 100) and Last is the last digit (Value MOD 10). The value is output if they match. Counter Value First Last Limit OUTPUT 0 0 8 1 66 2 606 6 6 606 3 6226 4 8448 5 642 6 2 6 747 7 7 747 7 77 8 121 1 1 121 Counter and Limit columns correct [1] Value column correct [1] First column correct [1] Last column correct [1] OUTPUT column correct [1] (b) Look at what is output. It checks for 3-digit numbers [1] ...and outputs those where the first and last digits are the same [1] KEY IDEA In a trace table, change a variable's column only on the line that changes it; unchanged values are left blank. TOTAL 7 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.