9618/21 · May/June 2025 · Worked solutions

Step-by-step solutions based on the mark scheme (not a mark-scheme dump).

Question 1

Paper page 2 for Q1
Original paper page 2

Part 1(a) — solution

Answer: 4

4 Example Explanation Variable name Data type value "Fruit" a category of stock that is Category STRING sold in the shop 20/02/2025 when an item was sold DateSold DATE 12.67 the cost of an item (Item)Cost/Price REAL TRUE to indicate if an item is in (Item)InStock BOOLEAN stock Mark as follows:

Mark points

  • Correct result: 4

Part 1 — solution

mark per row for each variable name and data type

Mark points

  • Include the ideas shown in the solution above.

Part 1(b) — solution

Answer: 5

  1. IF Sales[Current] <= 150 THEN ✓ ✓

Mark points

  • IF Sales[Current] <= 150 THEN ✓ ✓

Part 1(c) — solution

Decomposition involves: 3 MP1 Breaking down a problem into sub problems MP2 In order to explain / understand the process/task of how a (stock control) can be managed in more detail MP3 Leading to the concept of the program designed as a series of modules / procedures / functions // or by example of different stock control modules MP4 Makes the program easier to test / debug Max 3 Max 2 if no mention of stock control University Press & Assessment 2025 Page 6 of 14 9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2025

Mark points

  • Include the ideas shown in the solution above.

Part 1 — solution

'D' MP3 'H'

Mark points

  • Include the ideas shown in the solution above.

Question 2

Paper page 4 for Q2
Original paper page 4

Part 2(a)(i) — solution

MP1 The two decision boxes are in the wrong order // 1 The first decision symbol is wrong MP2 The first decision should check for values greater than or equal to 2000 Max 1

Mark points

  • Include the ideas shown in the solution above.

Part 2(a)(ii) — solution

Explaining how to correct the flowchart. 1 MP1 Swap around the two decision boxes MP2 The first decision box should check for values greater than or equal to 2000 and the second decision box should check for values above 4000 Max 1

Mark points

  • Include the ideas shown in the solution above.

Part 2(b)(i) — solution

2000 / 4000 / 10 / 100 1

Mark points

  • Include the ideas shown in the solution above.

Part 2(b)(ii) — solution

MP1 The value cannot be changed // avoids being different in two places 2 MP2 Makes the program easier to understand MP3 Avoids repeatedly writing the same value throughout the program MP4 A change to the value requires a change in only one statement Max 2

Mark points

  • Include the ideas shown in the solution above.

Part 2(b)(iii) — solution

MP1 (The code is) tried and tested so error free 1 MP2 Provides functionality / code that the programmer may find difficult to code themselves Max 1

Mark points

  • Include the ideas shown in the solution above.

Part 2(c) — solution

MP1 Syntax (error) 4 MP2 Rules of programming language // the language grammar was not followed MP3 Run-time (error) MP4 The program performs an illegal operation Mark as follows: One mark for naming each type of error and one mark for the description University Press & Assessment 2025 Page 7 of 14 9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2025

Mark points

  • Include the ideas shown in the solution above.

Part 2 — solution

'D' 'T' 'H' 'R' 'T' 1 'D' MP1

Mark points

  • Include the ideas shown in the solution above.

Part 2 — solution

'H' (‘R’) MP4 'R'

Mark points

  • Include the ideas shown in the solution above.

Question 3

Part 3 — solution

  1. UNTIL Guess = GeneratedValue

Mark points

  • UNTIL Guess = GeneratedValue

Part 3 — solution

'H' 2 'T' 'T' MP2

Mark points

  • Include the ideas shown in the solution above.

Question 4

Paper page 8 for Q4
Original paper page 8

Part 4(a) — solution

MP1 Count-controlled 2 MP2 The number of iterations required is known

Mark points

  • Include the ideas shown in the solution above.

Part 4(b) — solution

I Key J Chars[J] Chars 6 [1] [2] [3] [4]

Mark points

  • Include the ideas shown in the solution above.

Part 4 — solution

'R' 3 'T' 'T'

Mark points

  • Include the ideas shown in the solution above.

Question 5

Paper page 10 for Q5
Original paper page 10

Part 5 — solution

MP5 Chars array final values MP6 'D' 'H' 'R' 'T' Mark as follows: MP1, MP2, MP3, MP4, MP5

Mark points

  • Include the ideas shown in the solution above.

Part 5 — solution

MP1 Pop an item off the stack 7 MP2 Update Stack pointer MP3 Add it to the queue MP4 Update Rear pointer MP5 Repeat until the stack is empty MP6 Remove an item from the queue MP7 Update Front pointer MP8 Push it onto the stack MP9 Update the Stack pointer MP10 Repeat until the queue is empty Max 7

Mark points

  • Include the ideas shown in the solution above.

Question 6

Paper page 12 for Q6
Original paper page 12

Part 6(a) — solution

Answer: 4

  1. abnormal >= 61 data item is rejected

Mark points

  • abnormal >= 61 data item is rejected

Part 6(b) — solution

  1. Conditional outer loop including flag reset
  2. Flag set in inner loop to indicate swap

Mark points

  • Conditional outer loop including flag reset
  • Flag set in inner loop to indicate swap

Question 7

Paper page 14 for Q7
Original paper page 14

Part 7(a) — solution

  1. WHILE NewPoints >= 11 AND Number > 0

Mark points

  • WHILE NewPoints >= 11 AND Number > 0

Part 7(b)(i) — solution

Example solution: 8 PROCEDURE AddNewCustomers(NumToAdd : INTEGER) DECLARE CustomerID : INTEGER DECLARE Count : INTEGER DECLARE Line : STRING DECLARE NewLine : STRING OPENFILE "Loyalty.txt" FOR READ WHILE NOT EOF("Loyalty.txt") READFILE "Loyalty.txt", Line ENDWHILE CLOSEFILE "Loyalty.txt" OPENFILE "Loyalty.txt" FOR APPEND CustomerID  STR_TO_NUM((LEFT(Line, 6)) FOR Count  1 TO NumToAdd CustomerID  CustomerID + 1 OUTPUT CustomerID NewLine  NUM_TO_STR(CustomerID) & ",0" WRITEFILE "Loyalty.txt", NewLine NEXT Count CLOSEFILE "Loyalty.txt" ENDPROCEDURE Mark as follows: MP1 All variables used are declared using the correct type including a string and an integer MP2 Open file in read mode and close (before opening in append mode) MP3 Conditional loop with EOF("Loyalty.txt") MP4 Read Line from file // Count number of records in the file MP5 Open the file in append mode and subsequently close MP6 Extract CustomerID from Line and convert to integer // use count from MP4 to generate last CustomerID stored MP7 A (count controlled) loop for the number of customers to add MP8 Increment CustomerID and output the new CustomerID in loop MP9 Create string for new CustomerID and write to file in loop Max 8 University Press & Assessment 2025 Page 13 of 14 9618/21 Cambridge International AS & A Level – Mark Scheme May/June 2025

Mark points

  • Include the ideas shown in the solution above.

Part 7(b)(ii) — solution

Answer: 100001

MP1 Check if the text file loyalty.txt exists / is empty 4 MP2 If file does not exist it must be created (using write mode) MP3 If the file has to be created / is empty then set the first CustomerID to 100001 MP4 Write "100001,0" to loyalty.txt (using write mode) MP5 For all but the first customer (to be added to the empty file) use the existing code / module Max 4 University Press & Assessment 2025 Page 14 of 14

Mark points

  • Correct result: 100001