An original Thinka practice paper modelled on the structure and difficulty of the Jun 2023 (V2) Cambridge IGCSE Computer Science (0478) paper. Not affiliated with or reproduced from Cambridge.
Paper 12 Computer Systems
Answer all questions. Calculators must not be used.
10 Question · 75 marks
Question 1 · Short Answer
3 marks
An embedded system developer uses hexadecimal notation instead of binary when defining memory-mapped input/output addresses. State three reasons why the developer would prefer to represent binary numbers in hexadecimal format.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Hexadecimal is used as a human-friendly shorthand for binary numbers because: 1. Shorter representation: Hexadecimal uses fewer digits (one hex digit per four binary bits), which is more compact and takes up less screen space. 2. Readability: It is much easier for programmers to read, write, and understand compared to long strings of 1s and 0s. 3. Less error-prone: Because the numbers are shorter and easier to parse visually, programmers are far less likely to make transcription or data entry mistakes.
Marking scheme
Award 1 mark per correct reason, up to a maximum of 3 marks: - Shorter / more compact representation // takes up less screen space - Easier/quicker to read, write, or understand - Fewer errors/mistakes are likely to be made (when copying/entering) - Easier to troubleshoot/debug (the code) (Note: Reject "saves storage space / memory" as hexadecimal is only used for human representation; in memory, it is still stored as binary.)
Question 2 · Short Answer
3 marks
An operating system uses interrupts to manage various signals from hardware devices and software programs. Explain what happens when a hardware device, such as a printer, generates an interrupt signal while the CPU is executing a user program.
Show answer & marking schemeHide answer & marking scheme
Worked solution
When a hardware device generates an interrupt, the CPU temporarily stops executing the current user program. First, it saves the current status/state (including the program counter and register values) so it can return to it later. Second, it loads and executes the specific interrupt handler, known as the Interrupt Service Routine (ISR), to service the hardware request. Finally, once the ISR finishes, the CPU restores the saved state of the user program and resumes its execution from where it left off.
Marking scheme
Award 1 mark per correct point, up to a maximum of 3 marks: - The CPU suspends/stops the execution of the current program/task. - The CPU saves the current status / registers / program counter. - The CPU identifies the interrupt source and runs/executes the Interrupt Service Routine (ISR) / handles the interrupt. - Once the interrupt is handled, the saved state is restored and execution of the suspended program resumes.
Question 3 · Short Answer
3 marks
A local network transfers files between computers. A checksum is used to detect transmission errors. Describe how a checksum is used to verify that a file has been transmitted without errors.
Show answer & marking schemeHide answer & marking scheme
Worked solution
To verify a transmission using a checksum: 1. Calculation at Sender: Before sending, the sender uses a mathematical algorithm to calculate a checksum value based on the binary data of the file. 2. Transmission: The calculated checksum is sent along with the file to the destination. 3. Calculation and Comparison at Receiver: The receiver applies the identical algorithm to the received file to compute its own checksum. It then compares this computed checksum with the transmitted checksum. If the values are identical, the file is assumed to have arrived without errors. If they differ, an error has occurred, and the receiver requests a retransmission.
Marking scheme
Award 1 mark per point, up to a maximum of 3 marks: - The sender calculates a checksum value from the data using an algorithm / formula before transmission. - The checksum value is transmitted alongside the data. - The receiver applies the same algorithm/formula to the received data to calculate its own checksum. - The receiver compares the calculated checksum with the received checksum. - If the two values match, the data is error-free // if they do not match, an error is detected (and a request for retransmission is made).
Question 4 · Short Answer
3 marks
Explain how lossy compression reduces the file size of an image and state why a professional photographer might choose lossless compression instead.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Lossy compression algorithms reduce file sizes by permanently removing data that the human eye cannot easily perceive, such as subtle variations in color shades. A professional photographer, however, would avoid this and select lossless compression because it retains every single bit of original data without degrading image quality, which is critical when editing, printing, or archiving high-quality photos.
Marking scheme
Award 1 mark per point, up to a maximum of 3 marks: - Lossy compression permanently discards/deletes data from the file. - It identifies and removes redundant/unnecessary data (e.g., color shades the human eye cannot distinguish easily). - Lossless compression is chosen because it retains all original data / does not degrade image quality / allows perfect reconstruction of the original file.
Question 5 · Short Answer
3 marks
The Program Counter (PC) is a key register within the CPU's Control Unit. Describe the role of the Program Counter in the Fetch-Decode-Execute cycle, including how its value changes.
Show answer & marking schemeHide answer & marking scheme
Worked solution
During the Fetch-Decode-Execute cycle, the Program Counter (PC) plays a critical role: 1. It stores the memory address of the next instruction scheduled for execution. 2. At the start of the fetch stage, the address in the PC is copied to the Memory Address Register (MAR) via the address bus. 3. Immediately after this address is copied, the PC is incremented by 1, preparing it to point to the next instruction in sequence for the subsequent cycle.
Marking scheme
Award 1 mark per point, up to a maximum of 3 marks: - Stores/holds the address of the next instruction to be fetched/executed. - This address is copied/sent to the Memory Address Register (MAR) (at the start of the fetch stage). - The Program Counter is incremented (by 1) (to point to the subsequent instruction).
Question 6 · Structured Theory
12 marks
1 (a) Convert the two binary numbers to hexadecimal.
(b) A value is stored as an 8-bit binary number in a register:
0 0 1 1 0 1 1 0
A logical left shift of two places is performed on the binary number.
(i) Complete the binary register to show its contents after this logical left shift. [1]
(ii) State the mathematical effect of this logical left shift on the binary number and explain a potential problem that can occur when performing a left shift on a register of fixed size. [2]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) (i) D6B (ii) 3C5 (b) (i) [ 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 ] (ii) Mathematical effect: Multiplies the value by 4 (since shifting left by $n$ places multiplies by $2^n$). Potential problem: Overflow error. If any highly significant '1' bits are shifted out of the left end of the register, they are lost, resulting in an incorrect final value. (c) Reasons for using hexadecimal: 1. It is easier and quicker for humans to read, write, and understand than long strings of binary. 2. It is much easier to debug and find errors in code. 3. It takes up less screen space. Why computers process in binary: Computer processors are made of millions of tiny switches (transistors) that can only exist in one of two stable physical states: on (represented as 1) or off (represented as 0).
Marking scheme
(a) One mark per each correct character in the correct order: - D, 6, B (2 marks) - 3, C, 5 (2 marks)
(b) (i) One mark for correct binary contents: - 11011000 (1 mark) (ii) One mark for mathematical effect and one mark for potential problem: - Multiplies the number by 4 (1 mark) - Risk of overflow / loss of significant bits (1 mark)
(c) Maximum three marks for hexadecimal benefits: - Easier/quicker to read, write, and understand (1 mark) - Shorter representation / takes up less screen space (1 mark) - Less likely to make mistakes / easier to debug (1 mark) Maximum two marks for binary format necessity: - Computer systems are built from transistors / logic gates (1 mark) - These only have two stable states (on/off, high/low voltage), which maps perfectly to 1 and 0 (1 mark)
Question 7 · Structured Theory
12 marks
2 (a) Describe the role of the Program Counter (PC) and the Memory Address Register (MAR) during the fetch stage of the fetch-decode-execute cycle. [4]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) The Program Counter (PC) holds the address of the next instruction to be fetched from memory. This address is then copied from the PC to the Memory Address Register (MAR) via the address bus. Once copied, the PC is incremented by one so that it points to the address of the subsequent instruction. (b) (i) An interrupt is a signal sent from a device or software program to the processor. It alerts the processor that an event has occurred that requires immediate attention, causing the processor to temporarily suspend its current execution cycle to run an interrupt service routine (ISR). (ii) Sources: Input/Output hardware request (e.g., printer out of paper, keyboard keystroke), hardware fault (e.g., power failure), or software error (e.g., division by zero). (c) 1. Control Unit (CU): Decodes instructions and sends control signals to coordinate the flow of data within the CPU. 2. Arithmetic Logic Unit (ALU): Performs arithmetic operations (like addition and subtraction) and logical comparisons (like AND, OR, and NOT). 3. Internal/System Clock: Emits regular electrical pulses to synchronize all CPU operations.
Marking scheme
(a) One mark per descriptive point, max 4: - Program Counter (PC) holds the address of the next instruction to be fetched (1 mark) - This address is copied from the PC to the MAR (1 mark) - This address is transmitted using the address bus (1 mark) - The PC is incremented (by 1) (1 mark)
(b) (i) One mark per point, max 2: - A signal sent to the processor from a device/software (1 mark) - Requesting processor attention / temporarily suspends current execution to run an ISR (1 mark) (ii) One mark per correct source, max 3: - Hardware error (e.g., disk read fail) (1 mark) - I/O request (e.g., keyboard input, printer out of paper) (1 mark) - Software error (e.g., division by zero) (1 mark) - Timer signal (1 mark)
(c) One mark for each component and its correct function, max 3: - Control Unit (CU) - decodes instructions / directs data flow (1 mark) - Arithmetic Logic Unit (ALU) - performs calculations / logical operations (1 mark) - Clock - synchronizes processing components (1 mark)
Question 8 · Structured Theory
12 marks
3 (a) Complete the paragraph about how a web page is requested and displayed, using terms from the list.
Some of the terms in the list will not be used. Some terms may be used more than once.
Cookie, DNS server, HTML, HTTP/HTTPS, IP address, MAC address, URL, Web browser, Web server
A user enters a website's ........................................................... into their ........................................................... . This application sends the domain name to a ........................................................... to find the corresponding ........................................................... . A request is then sent to the ........................................................... hosting the website using the ........................................................... protocol. [6]
(b) Cyber security threats are a major concern for online systems.
(i) Define what is meant by 'phishing' and explain how it differs from 'pharming'. [4]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) URL, Web browser, DNS server, IP address, Web server, HTTP/HTTPS (b) (i) Phishing is a social engineering attack where malicious actors send fraudulent messages (usually emails) designed to look legitimate, in order to trick users into sharing sensitive data (like passwords or credit card numbers). Pharming is a cyberattack where traffic from a legitimate website is hijacked and redirected to a fake replica website. The key difference is that phishing relies on the user actively clicking a deceptive link in a message, whereas pharming operates silently behind the scenes by installing malicious code on a computer or poisoning DNS servers, redirecting users even if they typed the correct address. (ii) Protection methods: - Look closely for spelling mistakes and poor grammar in the message text. - Check the actual domain name of the sender's email address rather than just the friendly display name.
Marking scheme
(a) One mark for each correct term in order: 1. URL 2. Web browser 3. DNS server 4. IP address 5. Web server 6. HTTP/HTTPS
(b) (i) One mark for definition of phishing: - Sending fake emails to trick users into providing credentials/data (1 mark) One mark for definition of pharming: - Redirecting user traffic to a fake website using malicious software or DNS manipulation (1 mark) Two marks for contrast/differences (max 2): - Phishing requires the user to click a link to proceed (1 mark) - Pharming redirects users automatically even if they type the correct URL (1 mark)
(ii) One mark for each valid protection method, max 2: - Check for poor spelling / grammatical errors (1 mark) - Examine the sender's email domain address (1 mark) - Avoid clicking links; go directly to the official website (1 mark) - Use two-factor authentication (2FA) (1 mark)
Question 9 · Structured Theory
12 marks
4 An automated climate control system is installed in a large commercial greenhouse to maintain optimal growth conditions for rare plants. The system must maintain a constant temperature between 18°C and 24°C, and ensure soil moisture does not fall below a set limit.
(a) (i) Identify two sensors that would be suitable for use in this system. [2]
(ii) Identify two actuators that would be used in this system. [2]
(iii) Describe how the sensors, microprocessor, and actuators work together to automatically control the environment in the greenhouse. [5]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) (i) Temperature sensor and soil moisture (humidity) sensor. (ii) Heater, cooling fan, water valve/pump, or window motor. (iii) The sensors continuously collect analogue environmental data and send it to an Analogue-to-Digital Converter (ADC). The ADC converts this to digital data, which is passed to the microprocessor. The microprocessor compares these values to the preset limits (18°C–24°C for temperature, and the moisture threshold). If a value is outside the limits, the microprocessor sends digital control signals to turn an actuator on or off (e.g., turning on the heater if the temperature is below 18°C, or opening water pumps if the soil is dry). The digital signal is converted back to analogue if the actuator requires it. This process operates continuously in a feedback loop. (b) A capacitive touch screen contains a glass panel coated with a transparent, charge-storing conductive layer. When a user's finger (which conducts electricity) touches the screen, it draws an electrical current from that point, creating a change in the electrostatic capacitance. Sensors at the corners of the screen measure this difference, and a microprocessor calculates the precise coordinates of the touch.
Marking scheme
(a) (i) One mark per correct sensor, max 2: - Temperature sensor (1 mark) - Moisture / humidity sensor (1 mark) (ii) One mark per correct actuator, max 2: - Heater / heating element (1 mark) - Fan / cooling pump (1 mark) - Water pump / motorized valve (1 mark) - Vent / window motor (1 mark) (iii) One mark per descriptive point, max 5: - Sensors continuously capture analogue data (1 mark) - Analogue data is converted to digital via an ADC (1 mark) - Microprocessor compares digital data against pre-programmed ranges (1 mark) - If out of range, microprocessor sends signal to actuator (1 mark) - Actuators operate (e.g., heater turns on) to bring condition back to set limit (1 mark) - System runs continuously in a feedback loop (1 mark)
(b) One mark per descriptive point, max 3: - Screen features a transparent conductive/charge-storing layer (1 mark) - Touching screen with a finger draws a current / disrupts the electrostatic field (1 mark) - The resulting change in capacitance is detected by sensors (1 mark) - Microprocessor calculates the exact X-Y coordinates of the touch (1 mark)
Question 10 · Structured Theory
12 marks
5 (a) A logic circuit has three inputs: A, B, and C. The output X is 1 if (A is NOT 1 AND B is 1) OR (B is NOT 1 AND C is 1).
(i) Write the logic expression for this system. [3]
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) (i) $X = (\text{NOT } A \text{ AND } B) \text{ OR } (\text{NOT } B \text{ AND } C)$ (ii) Let's evaluate the expression for each row: - Row 1 (0,0,0): (1 AND 0) OR (1 AND 0) -> 0 OR 0 = 0 - Row 2 (0,0,1): (1 AND 0) OR (1 AND 1) -> 0 OR 1 = 1 - Row 3 (0,1,0): (1 AND 1) OR (0 AND 0) -> 1 OR 0 = 1 - Row 4 (0,1,1): (1 AND 1) OR (0 AND 1) -> 1 OR 0 = 1 - Row 5 (1,0,0): (0 AND 0) OR (1 AND 0) -> 0 OR 0 = 0 - Row 6 (1,0,1): (0 AND 0) OR (1 AND 1) -> 0 OR 1 = 1 - Row 7 (1,1,0): (0 AND 1) OR (0 AND 0) -> 0 OR 0 = 0 - Row 8 (1,1,1): (0 AND 1) OR (0 AND 1) -> 0 OR 0 = 0
Output $X$ values from top to bottom: 0, 1, 1, 1, 0, 1, 0, 0.
(b) (i) Two differences: 1. A compiler translates the entire source code in one operation into machine code (object code), whereas an interpreter translates and executes the source code line-by-line. 2. A compiler generates a standalone executable file (e.g., .exe), so the program can run on another computer without needing the compiler. An interpreter does not produce an executable file; the interpreter must always be present to run the code. (ii) Interpreters stop executing immediately at the exact line where a syntax error is found. This helps the developer locate and fix bugs much faster.
Marking scheme
(a) (i) Three marks for correct logic expression: - (NOT A AND B) (1 mark) - (NOT B AND C) (1 mark) - OR joining the components (1 mark) (ii) Four marks for correct X output column: - 4 marks for all 8 correct outputs: 0, 1, 1, 1, 0, 1, 0, 0 - 3 marks for 6 or 7 correct outputs - 2 marks for 4 or 5 correct outputs - 1 mark for 2 or 3 correct outputs
(b) (i) Two marks per difference, max 4 (must address both compiler and interpreter for each point): - Translation method: Compiler translates whole source code at once // Interpreter translates code line-by-line (2 marks) - Output file: Compiler produces a separate executable machine code file // Interpreter does not produce an object/executable file (2 marks) - Execution speed: Compiler code runs faster once compiled // Interpreter code runs slower because translation occurs on the fly (2 marks) (ii) One mark for advantage: - Facilitates easier / faster debugging (1 mark)
Ready to test yourself?
Turn these notes into exam-style practice. Get unlimited AI questions on this topic with instant marking and explanations.
Answer all questions. Calculators must not be used.
9 Question · 53 marks
Question 1 · Short Answer
4 marks
A security alarm system has three inputs representing sensors: \(A\) (motion detector), \(B\) (door sensor), and \(C\) (window sensor). The alarm system output \(X\) is 1 (activated) if: - Motion detector \(A\) is active AND door sensor \(B\) is active, - OR - Window sensor \(C\) is active AND motion detector \(A\) is NOT active.
(a) Write a logic expression to represent this security system using the terms AND, OR, and NOT. (b) State the value of \(X\) for each of the following scenarios: (i) \(A = 0, B = 1, C = 1\) (ii) \(A = 1, B = 0, C = 1\)
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) Combining the two conditions with OR gives: \(X = (A \text{ AND } B) \text{ OR } (C \text{ AND NOT } A)\). (b) (i) When \(A = 0, B = 1, C = 1\), the first part \(A \text{ AND } B = 0\), but the second part \(C \text{ AND NOT } A = 1 \text{ AND } 1 = 1\). Thus \(X = 0 \text{ OR } 1 = 1\). (ii) When \(A = 1, B = 0, C = 1\), the first part \(A \text{ AND } B = 0\), and the second part \(C \text{ AND NOT } A = 1 \text{ AND } 0 = 0\). Thus \(X = 0 \text{ OR } 0 = 0\).
Marking scheme
(a) 2 marks: - 1 mark for: `(A AND B)` - 1 mark for: `OR (C AND NOT A)` (or equivalent logic) (b) 2 marks: - 1 mark for: (i) X = 1 - 1 mark for: (ii) X = 0
Question 2 · Short Answer
4 marks
A bookstore database has a table named `Books` to store details of items. (a) State the most appropriate data type for the fields `BookID` (e.g. BK902) and `Price` (e.g. 12.99). (b) Explain the purpose of the following SQL statement: `SELECT Title, Price FROM Books WHERE InStock = TRUE ORDER BY Price DESC;`
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) `BookID` contains both letters and numbers, making Text or Alphanumeric the most appropriate data type. `Price` contains fractional numbers, so Real, Decimal, or Currency is the correct data type. (b) The `SELECT` clause retrieves the Title and Price. The `WHERE` clause filters only books that are currently in stock. The `ORDER BY Price DESC` clause sorts the output in descending order of price (highest first).
Marking scheme
(a) 2 marks: - 1 mark for BookID: Text / Alphanumeric / String - 1 mark for Price: Real / Decimal / Currency / Single / Double (b) 2 marks: - 1 mark for identifying that it displays Title and Price of books that are in stock - 1 mark for identifying that it is sorted in descending order of Price (highest to lowest)
Question 3 · Short Answer
4 marks
A registration program requires a user to enter their age and a newly created password. The rules for the inputs are: - The age must be a whole number between 13 and 120 inclusive. - The password must not be empty and must be entered twice to ensure it was typed correctly.
(a) Identify two different validation checks that should be performed on the age input. (b) Identify and describe the verification check used to ensure the password has been entered without typing errors.
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) A Range check verifies if the age is between 13 and 120. A Type check checks that the entered value is an integer/whole number. (b) The verification technique is Double-entry. The system requests the password twice and compares the entries to verify they are identical, which ensures no typing errors were made.
Marking scheme
(a) 2 marks: - 1 mark for: Range check - 1 mark for: Type check / Character check / Format check (b) 2 marks: - 1 mark for: identifying Double-entry check - 1 mark for: explaining that the two entered passwords are compared to ensure they match
Question 4 · Short Answer
4 marks
A programmer needs to write a pseudocode algorithm that appends the text stored in a variable `NewEntry` to an existing sequential file named `history.txt`. Describe the four essential steps, in the correct order, that the algorithm must perform to successfully append the data and ensure it is saved.
Show answer & marking schemeHide answer & marking scheme
Worked solution
The logical sequence for file writing is: 1. Open the file in the correct mode (APPEND or WRITE). 2. Fetch the text to be added. 3. Write the value of the variable into the file. 4. Close the file to commit the changes and free the system resource.
Marking scheme
4 marks for the four steps described in the correct chronological order: - 1 mark for: Open `history.txt` - 1 mark for: Specifying append mode / write mode - 1 mark for: Writing/appending the variable `NewEntry` to the file - 1 mark for: Closing the file `history.txt`
Question 5 · Short Answer
4 marks
Consider this segment of pseudocode:
```text 01 Total <- 0 02 Counter <- 0 03 REPEAT 04 INPUT Value 05 IF Value > 100 06 THEN 07 Total <- Total + Value 08 Counter <- Counter + 1 09 ENDIF 10 UNTIL Counter = 5 ```
(a) Identify the type of loop used in this pseudocode. (b) State the purpose of the statement on line 08. (c) Explain what would happen if the user inputs five numbers that are all less than 100.
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) The loop is controlled by a condition evaluated at the end: `REPEAT...UNTIL`, which is a post-condition loop. (b) Line 08 increments `Counter` by 1. Its purpose is to count the number of values inputted that are greater than 100. (c) Since all five inputs are less than 100, the condition on line 05 is never true. Line 08 is never executed. `Counter` remains 0, meaning the termination condition `Counter = 5` is never satisfied, resulting in an infinite loop.
Marking scheme
(a) 1 mark: - Post-condition loop // REPEAT...UNTIL loop (b) 1 mark: - Increments the loop counter / tracks the number of inputs greater than 100 (c) 2 marks: - 1 mark for: loop runs infinitely / never terminates / continues to ask for input - 1 mark for: Counter is never incremented (remains 0) because the IF condition `Value > 100` is never met
Question 6 · Short Answer
4 marks
A programmer is writing a program and needs to decide whether to use a procedure or a function for two different tasks. - Task 1: Calculate and return the area of a circle given its radius. - Task 2: Display a menu of options on the screen.
(a) Identify the most appropriate subroutine type (procedure or function) for: (i) Task 1 (ii) Task 2 (b) State two general differences between a procedure and a function.
Show answer & marking schemeHide answer & marking scheme
Worked solution
(a) (i) Task 1 needs to calculate and pass back a single value (area), which is the role of a Function. (ii) Task 2 executes a set of instructions (displaying text) but does not return a value, which is appropriate for a Procedure. (b) Functions must return a value, can be used in expressions, and typically do not change global variables, whereas procedures perform tasks without returning a value and are called independently.
Marking scheme
(a) 2 marks: - 1 mark for (i) Function - 1 mark for (ii) Procedure (b) 2 marks for any two of: - A function must return a value // a procedure does not return a value - A function is called as part of an expression/assignment // a procedure is called as a standalone instruction - A function has a return data type defined // a procedure does not
Question 7 · Trace Table
7 marks
An algorithm is represented by the following pseudocode. The array `List[1:6]` contains the values: `[12, 5, 8, 12, 3, 15]`.
``` 01 Count <- 0 02 Index <- 1 03 Limit <- 6 04 Target <- 10 05 REPEAT 06 IF List[Index] > Target THEN 07 List[Index] <- List[Index] - 5 08 Count <- Count + 1 09 ELSE 10 List[Index] <- List[Index] + 2 11 ENDIF 12 Index <- Index + 1 13 UNTIL Index > Limit 14 OUTPUT Count ```
- **Output (Line 14):** - Outputs `Count` which contains the value 3.
Marking scheme
Award marks according to the following guidelines (up to a maximum of 7 marks): - **1 mark** for initial values of Count (0) and Index (1) correctly written on the first row. - **1 mark** for correct updates to List[1] (7) and Count (1) in the first iteration. - **1 mark** for correct updates to List[2] (7) and List[3] (10) across respective iterations. - **1 mark** for correct update to List[4] (7) and Count (2). - **1 mark** for correct updates to List[5] (5) and List[6] (10) and Count (3). - **1 mark** for correct tracking of Index incrementing sequentially up to 7. - **1 mark** for correct final OUTPUT of 3.
Question 8 · Trace Table
7 marks
A program contains the following algorithm designed to process two numerical values:
``` 01 A <- 4 02 B <- 15 03 C <- 0 04 WHILE B > A DO 05 IF B MOD 2 = 0 THEN 06 B <- B - 3 07 C <- C + A 08 ELSE 09 B <- B - 1 10 A <- A + 1 11 ENDIF 12 ENDWHILE 13 OUTPUT A, B, C ```
Complete the trace table for this algorithm. Show the state of variables after each change.
| A | B | C | OUTPUT | | :---: | :---: | :---: | :---: | | | | | |
Show answer & marking schemeHide answer & marking scheme
- **Output (Line 13):** Outputs `A, B, C` which translates to `7, 6, 11`.
Marking scheme
Award marks according to the following guidelines (up to a maximum of 7 marks): - **1 mark** for correct initial values of A (4), B (15), C (0). - **1 mark** for the first state change showing B = 14 and A = 5. - **1 mark** for the second state change showing B = 11 and C = 5. - **1 mark** for the third state change showing B = 10 and A = 6. - **1 mark** for the fourth state change showing B = 7 and C = 11. - **1 mark** for the fifth state change showing B = 6 and A = 7. - **1 mark** for the correct final output: `7, 6, 11` (all three values required).
Question 9 · Extended Programming Project
15 marks
A library management program utilizes a two-dimensional (2D) array `BookCatalog[]` to store the title and author of each book.
Another 2D array, `RentalStatus[]`, contains details regarding the rental state of each book: * column one stores the availability status (0 for available, 1 for borrowed) * column two stores the Member ID of the borrower (0 if the book is currently available) * column three stores the daily rental cost in dollars, for example 1.50
The internal Book ID serves as the row index for both arrays. For example, Book ID 15's details would be stored in: `BookCatalog[15,1]` and `BookCatalog[15,2]` `RentalStatus[15,1]`, `RentalStatus[15,2]` and `RentalStatus[15,3]`
The variable `CatalogSize` contains the total number of books in the library's catalog.
The arrays and the variable `CatalogSize` have already been set up and the data has been stored.
Write a program that meets the following requirements: * checks if a Book ID entered by the user exists in the catalog before any action can take place * displays a menu showing the four actions available for the user to choose from: 1. display book details and status 2. borrow book 3. return book 4. exit * allows an action to be chosen and completed. Each action must be completed by a procedure with a parameter of the Book ID.
You must use pseudocode or program code and add comments to explain how your code works. All inputs and outputs must contain suitable messages.
You only need to declare any local arrays and local variables that you use.
You do not need to declare and initialise the data in the global arrays `BookCatalog[]` and `RentalStatus[]` and the variable `CatalogSize`.
Show answer & marking schemeHide answer & marking scheme
Worked solution
Below is an example solution written in pseudocode:
``` // Procedure to display details of a selected book PROCEDURE DisplayBook(BookID : INTEGER) OUTPUT "Book Title: ", BookCatalog[BookID, 1] OUTPUT "Author: ", BookCatalog[BookID, 2] IF RentalStatus[BookID, 1] = 0 THEN OUTPUT "Availability: Available" ELSE OUTPUT "Availability: Borrowed by Member ID ", RentalStatus[BookID, 2] ENDIF OUTPUT "Daily Rental Fee: $", RentalStatus[BookID, 3] ENDPROCEDURE
// Procedure to borrow a book PROCEDURE BorrowBook(BookID : INTEGER) DECLARE MemberID : INTEGER // Check if book is already borrowed IF RentalStatus[BookID, 1] = 1 THEN OUTPUT "Error: This book is already rented." ELSE // Loop to ensure a valid positive Member ID is supplied REPEAT OUTPUT "Enter Member ID: " INPUT MemberID UNTIL MemberID > 0
// Procedure to return a book and compute the charge PROCEDURE ReturnBook(BookID : INTEGER) DECLARE RentalDays : INTEGER DECLARE TotalCharge : REAL // Check if book is currently borrowed IF RentalStatus[BookID, 1] = 0 THEN OUTPUT "Error: This book is not currently rented." ELSE // Loop to obtain a valid positive rental duration REPEAT OUTPUT "Enter the number of days the book was rented: " INPUT RentalDays UNTIL RentalDays > 0
// Calculate and display total charges TotalCharge <-- RentalDays * RentalStatus[BookID, 3] OUTPUT "The total rental charge is: $", TotalCharge
// Reset status indicators RentalStatus[BookID, 1] <-- 0 RentalStatus[BookID, 2] <-- 0 OUTPUT "Book successfully returned and updated." ENDIF ENDPROCEDURE
// Main Program Execution DECLARE SelectedID, Choice : INTEGER DECLARE ValidID : BOOLEAN
// 1. Check if Book ID exists REPEAT OUTPUT "Please enter a Book ID (1 to ", CatalogSize, "): " INPUT SelectedID IF SelectedID >= 1 AND SelectedID <= CatalogSize THEN ValidID <-- TRUE ELSE OUTPUT "Error: Invalid Book ID. Please try again." ValidID <-- FALSE ENDIF UNTIL ValidID = TRUE
// 2. Display menu and handle actions REPEAT OUTPUT "*** LIBRARY SYSTEM MENU ***" OUTPUT "1. Display Book Details" OUTPUT "2. Borrow Book" OUTPUT "3. Return Book" OUTPUT "4. Exit" OUTPUT "Please select your choice (1-4): " INPUT Choice
CASE Choice OF 1 : CALL DisplayBook(SelectedID) 2 : CALL BorrowBook(SelectedID) 3 : CALL ReturnBook(SelectedID) 4 : OUTPUT "Exiting library system. Goodbye." OTHERWISE OUTPUT "Invalid choice. Please select from 1-4." ENDCASE UNTIL Choice = 4 ```
Marking scheme
### AO2: Apply knowledge and understanding (Max 9 marks)
#### Band 1 (1–3 Marks) * At least one programming technique (such as selection, iteration, or input/output) has been used. * Data structures have been referenced, but not fully or appropriately for all operations.
#### Band 2 (4–6 Marks) * Some programming techniques used are appropriate to the problem. * More than one technique (such as range validation on input and menu loop) is applied correctly. * Data structures chosen are appropriate and store/retrieve some of the necessary data correctly.
#### Band 3 (7–9 Marks) * The full range of programming techniques is applied effectively to cover all scenario requirements. * Book ID existence validation is successfully implemented. * A menu system with selection (e.g. `CASE` or nested `IF`) is fully integrated. * Procedures with the parameters are declared and used correctly to perform tasks. * Array operations correctly inspect and update data inside `RentalStatus[]`.
---
### AO3: Provide solutions to problems (Max 6 marks)
#### Band 1 (1–2 Marks) * Code is presented with limited or missing comments. * Variable and procedure identifiers are partially appropriate but may lack clarity. * The program logic is partially correct but contains several inaccuracies.
#### Band 2 (3–4 Marks) * The program contains some relevant comments explaining key sections. * The majority of identifier names are meaningful and appropriate to their purpose. * The solution contains parts that are illogical or inaccurate but achieves most requirements.
#### Band 3 (5–6 Marks) * The program is logically ordered, clean, and fully commented. * Highly suitable identifiers are used throughout. * The solution is accurate and performs all tasks effectively as described in the scenario (validating Book ID, processing borrow updates, calculating daily charges, resetting values upon return).
Wondering how well you actually know this?
thinka is an AI practice app for IGCSE & IB students: unlimited questions, instant auto-marking, and detailed step-by-step solutions. 100,000+ students use it to confirm they actually know it, not just think they do.