Cambridge IGCSE · thinka-original Practice Paper

2023 Cambridge IGCSE Computer Science (0478) Practice Paper with Answers

Thinka Jun 2023 (V1) Cambridge IGCSE-Style Mock — Computer Science (0478)

150 marks210 mins2023
An original Thinka practice paper modelled on the structure and difficulty of the Jun 2023 (V1) Cambridge IGCSE Computer Science (0478) paper. Not affiliated with or reproduced from Cambridge.

Paper 1 Computer Systems

Answer all questions. Calculators must not be used. Write answers clearly in spaces provided.
12 Question · 90 marks
Question 1 · structured
11 marks
Binary is a base-2 number system used by computers to represent and process data.

(a) Convert the denary number 141 to an 8-bit binary number. Show your working.
[2]

(b) Negative denary numbers can be represented in binary using two's complement.
Complete the 8-bit binary representation for the negative denary number -58. Show all your working.
[3]

(c) Two 8-bit binary numbers are given below. Add these two numbers together using binary addition. Show all your working, including any carry bits.

01101100
+ 00111010
[3]

(d) Explain what is meant by a binary overflow error and describe how it can occur during the addition of two 8-bit binary numbers.
[3]
Show answer & marking scheme

Worked solution

(a) To convert 141 to 8-bit binary:
- 141 >= 128, so the 128-bit is 1 (Remaining: 141 - 128 = 13)
- 13 < 64, so the 64-bit is 0
- 13 < 32, so the 32-bit is 0
- 13 < 16, so the 16-bit is 0
- 13 >= 8, so the 8-bit is 1 (Remaining: 13 - 8 = 5)
- 5 >= 4, so the 4-bit is 1 (Remaining: 5 - 4 = 1)
- 1 < 2, so the 2-bit is 0
- 1 >= 1, so the 1-bit is 1 (Remaining: 0)
Result: 10001101

(b) To represent -58 using 8-bit two's complement:
1. Represent +58 in 8-bit binary: 00111010
2. Invert (flip) all bits (one's complement): 11000101
3. Add 1 to the result: 11000101 + 1 = 11000110
Result: 11000110

(c) Perform binary addition:
Carries: 11110000
01101100 (108)
+ 00111010 (58)
-----------
10100110 (166)
Result: 10100110

(d) An overflow error occurs when the sum of two binary numbers exceeds the maximum value that can be represented within the system's bit limit (for an 8-bit unsigned system, this is 255). A carry-out is generated from the most significant bit (MSB), requiring a 9th bit. Since the register only holds 8 bits, the 9th bit is lost, leading to an incorrect result.

Marking scheme

(a) [2 marks total]:
- 1 mark for correct working (e.g. division by 2 or subtraction of powers of 2).
- 1 mark for correct final 8-bit binary value: 10001101.

(b) [3 marks total]:
- 1 mark for converting +58 correctly to binary (00111010).
- 1 mark for showing correct method (inverting bits and adding 1).
- 1 mark for correct final two's complement representation: 11000110.

(c) [3 marks total]:
- 1 mark for showing correct carry bits (at least 3 correct carries shown).
- 1 mark for correct left-hand nibble (1010).
- 1 mark for correct right-hand nibble (0110).

(d) [3 marks total]:
- 1 mark for definition: An error that occurs when a calculation produces a value that exceeds the register storage capacity.
- 1 mark for context: The register has a fixed/predetermined size of 8 bits.
- 1 mark for cause: Adding two numbers produces a result greater than 255 (or a 9th bit is generated/carried out of the MSB) which cannot be stored.
Question 2 · structured
11 marks
Binary is a base-2 number system used by computers.

(a) Convert the denary number **141** to an 8-bit binary number. Show your working.
[2]

(b) Negative denary numbers can be represented as binary using two's complement.
Complete the 8-bit binary representation for the negative denary number **-58**.
You must show all your working.
[3]

(c) Two 8-bit binary numbers are given below.
Add the two 8-bit binary numbers using binary addition. Show all your working, including carries.

```
0 1 1 0 1 1 0 0
+ 0 0 1 1 1 0 1 0
```
[3]

(e) An overflow error can occur when two binary numbers are added by a computer.
Explain what is meant by an overflow error and how it occurs in an 8-bit register.
[3]
Show answer & marking scheme

Worked solution

(a) To convert 141 to 8-bit binary:
- 141 - 128 = 13 (place value 128 has a 1)
- 64, 32, 16 are too large (place values have 0)
- 13 - 8 = 5 (place value 8 has a 1)
- 5 - 4 = 1 (place value 4 has a 1)
- 2 is too large (place value 2 has a 0)
- 1 - 1 = 0 (place value 1 has a 1)
Result: 10001101

(b) To convert -58 to two's complement:
- Convert +58 to binary: 00111010
- Invert all the bits (one's complement): 11000101
- Add 1: 11000110
Result: 11000110

(c) Binary Addition:
```
Carries: 1 1 1 1 0 0 0
0 1 1 0 1 1 0 0
+ 0 0 1 1 1 0 1 0
------------------
1 0 1 0 0 1 1 0
```
Result: 10100110

(d) Explanation of overflow:
- An overflow error occurs when the result of a calculation is too large to be represented within the allocated number of bits.
- In an 8-bit register, the maximum unsigned value that can be stored is 255.
- If a sum of two numbers exceeds 255, a 9th carry bit is generated from the MSB (most significant bit) which cannot be stored by the 8-bit register, causing the output to be truncated/incorrect.

Marking scheme

(a) [2 marks total]:
- 1 mark for correct working (e.g., showing division by 2 or subtraction of powers of 2).
- 1 mark for correct 8-bit binary number: 10001101.

(b) [3 marks total]:
- 1 mark for showing binary of +58 (00111010).
- 1 mark for showing inversion of bits (one's complement: 11000101) or another valid method step.
- 1 mark for correct final binary representation: 11000110.

(c) [3 marks total]:
- 1 mark for showing correct carry bits (at least 3 correct carries shown).
- 1 mark for correct left-hand nibble (1010).
- 1 mark for correct right-hand nibble (0110).

(d) [3 marks total] Three from:
- The result of the calculation is greater than 255.
- An 8-bit register has a predetermined/fixed limit of 8 bits.
- The result would require 9 bits to be represented.
- A carry bit is generated from the most significant bit (MSB) which has no space to be stored.
Question 3 · structural
10 marks
A voice-over artist records an audio file to be sent to a production studio over the internet.

(a) The quality and size of the audio file depend on the sampling rate and sampling resolution used.

(i) Describe what is meant by sampling rate. [1]

(ii) Describe what is meant by sampling resolution. [1]

(iii) State one benefit and one drawback of increasing both the sampling rate and the sampling resolution. [2]

(b) The audio file is split into packets and sent to the production studio using packet switching across a network.

(i) Identify two items of data, other than the packet payload, that are contained in the header of each packet. [2]

(ii) Explain how packet switching is used to transmit the audio file. [4]
Show answer & marking scheme

Worked solution

### Part (a)
(i) **Sampling rate** is the number of audio samples captured or recorded per second. It is measured in Hertz (Hz).
(ii) **Sampling resolution** (or bit depth) is the number of bits allocated to represent the amplitude of each individual sound sample.
(iii)
* **Benefit:** The recorded audio will have higher fidelity / dynamic range / accuracy to the original analogue sound.
* **Drawback:** The file size of the digital audio will be significantly larger, requiring more storage space and taking longer to transmit across the network.

### Part (b)
(i) Two items in a packet header (any two):
1. Destination IP address
2. Source / Sender IP address
3. Packet sequence number / ID
4. Packet length / size

(ii) **Explanation of packet switching:**
1. The large audio file is broken down / split into smaller units called packets.
2. Each packet is sent independently through the network.
3. Packets can take different physical routes/paths to reach the destination based on the current network traffic.
4. Routers inspect the destination IP address in the header of each packet to direct them to the next node.
5. Packets may arrive out of order at the destination.
6. The destination computer uses the packet sequence numbers to reassemble the packets in the correct order.
7. If any packet is lost, corrupted, or fails to arrive, a request is sent to retransmit that specific packet.

Marking scheme

### Part (a)(i) [1 Mark]
* 1 mark for describing sampling rate: The number of samples/recordings taken per second / unit of time.

### Part (a)(ii) [1 Mark]
* 1 mark for describing sampling resolution: The number of bits used to represent/store each sound sample.

### Part (a)(iii) [2 Marks]
* 1 mark for the benefit: e.g., Higher audio quality / more accurate representation / clearer sound / less distortion.
* 1 mark for the drawback: e.g., Larger file size / uses more memory / takes longer to upload/transmit / requires more bandwidth.

### Part (b)(i) [2 Marks]
* 1 mark per correct item (Max 2):
* Destination IP address
* Sender's / Source IP address
* Packet sequence number / packet ID
* Packet size / length
* Checksum / error-checking data

### Part (b)(ii) [4 Marks]
* Max 4 marks from:
* File is split/divided into packets [1]
* Packets travel independently through the network [1]
* Packets can take different routes / paths [1]
* Routers determine the optimal route / path [1]
* Packets can arrive out of order [1]
* The receiving computer reorders / reassembles the packets using the packet sequence numbers [1]
* Missing/corrupted packets are requested for retransmission [1]
Question 4 · short-answer
4 marks
A photographer wants to replace the Hard Disk Drive (HDD) in their desktop computer with a Solid-State Drive (SSD) to store and edit high-resolution images. Explain two benefits and two drawbacks to the photographer of making this change.
Show answer & marking scheme

Worked solution

Benefits: (1) Faster read/write speeds, which allows high-resolution images to be loaded and saved much quicker. (2) More durable and robust because it has no moving parts, reducing the risk of data loss due to physical shock. Drawbacks: (1) Higher cost per gigabyte, making it more expensive to store large archives of photos compared to an HDD of the same size. (2) Limited read/write endurance because SSD cells degrade over time with frequent write/erase cycles.

Marking scheme

One mark for each explained benefit (max 2 marks): - Faster read/write speeds / faster file transfer rates (1) - No moving parts / more durable / more robust against physical shock (1) - Silent operation / runs cooler / lower power consumption (1) One mark for each explained drawback (max 2 marks): - Higher cost per unit of storage / more expensive per gigabyte (1) - Lower maximum storage capacities available at reasonable price points compared to HDDs (1) - Limited number of read/write cycles / finite lifespan (1)
Question 5 · matching
4 marks
Software can be classified as system software or application software.

Complete the table by writing either System or Application next to each description.

DescriptionSoftware Type (System or Application)Software that provides a user interface to interact with the computer hardware...................................................Software that allows the user to perform specific task-oriented work, such as editing a video...................................................Software that includes programs like compilers, linkers, and device drivers...................................................Software that cannot run without an operating system already installed on the computer...................................................
Show answer & marking scheme

Worked solution

The completed table should be as follows:

DescriptionSoftware Type (System or Application)Software that provides a user interface to interact with the computer hardware.SystemSoftware that allows the user to perform specific task-oriented work, such as editing a video.ApplicationSoftware that includes programs like compilers, linkers, and device drivers.SystemSoftware that cannot run without an operating system already installed on the computer.Application

Marking scheme

Award 1 mark for each correct classification, up to a maximum of 4 marks:

- Description 1: System
- Description 2: Application
- Description 3: System
- Description 4: Application
Question 6 · matching
4 marks
Software can be classified as system software or application software.

Complete the table by writing either System or Application next to each description.

DescriptionSoftware Type (System or Application)Software that provides a user interface to interact with the computer hardware...................................................Software that allows the user to perform specific task-oriented work, such as editing a video...................................................Software that includes programs like compilers, linkers, and device drivers...................................................Software that cannot run without an operating system already installed on the computer...................................................
Show answer & marking scheme

Worked solution

The completed table should be as follows:

DescriptionSoftware Type (System or Application)Software that provides a user interface to interact with the computer hardware.SystemSoftware that allows the user to perform specific task-oriented work, such as editing a video.ApplicationSoftware that includes programs like compilers, linkers, and device drivers.SystemSoftware that cannot run without an operating system already installed on the computer.Application

Marking scheme

Award 1 mark for each correct classification, up to a maximum of 4 marks:

- Description 1: System
- Description 2: Application
- Description 3: System
- Description 4: Application
Question 7 · structured
7 marks
A museum has an automated preservation system to protect historical documents stored in a display case. The display case must be kept at a constant humidity level. If the humidity level rises above 50%, a dehumidifier is automatically turned on to lower the humidity.

The system uses a sensor and a microprocessor.

(a) State the name of the most suitable sensor for this control system.

(b) Explain how the sensor and the microprocessor work together to automatically control the dehumidifier to keep the humidity level within the display case safe.
Show answer & marking scheme

Worked solution

(a) A humidity sensor (or hygrometer) is used to detect the moisture level in the display environment.

(b) The humidity sensor constantly takes measurements of the moisture level inside the glass case. These analogue signals are sent to an Analogue-to-Digital Converter (ADC) because microprocessors can only interpret digital values. The microprocessor then compares the digital input against the pre-set limit of 50%. If the sensor's reading is greater than 50%, the microprocessor signals an actuator to turn the dehumidifier on. If the reading is 50% or below, the microprocessor signals the actuator to turn the dehumidifier off or keep it off. This loop repeats continuously to maintain a stable environment.

Marking scheme

(a) [1 mark max]
- Humidity sensor // Hygrometer

(b) [6 marks max]
- Sensor continuously measures the humidity level (of the display case) [1]
- Sensor sends data/readings to the microprocessor [1]
- Analogue data converted to digital using an Analogue-to-Digital Converter (ADC) [1]
- Microprocessor compares sensor values to stored/pre-set value (of 50%) [1]
- If value is greater than 50%, microprocessor sends signal to actuator [1]
- Actuator turns on the dehumidifier [1]
- If value is equal to or less than 50%, microprocessor sends signal to turn off / keep off dehumidifier [1]
- Process is repeated continuously / is a loop [1]
Question 8 · short_answer
6 marks
A company sets up a wireless local area network (WLAN) in its office to allow employees to connect their devices to a central server and the internet.

(a) (i) Identify the networking device used to connect wireless-enabled devices to the wired network.

(ii) Identify the networking device used to join the company's network to the internet, directing data packets between different networks.

(b) Every device connected to the network has both a Media Access Control (MAC) address and an Internet Protocol (IP) address.

(i) Describe the purpose of a MAC address.

(ii) Explain why both a MAC address and an IP address are necessary for a computer to communicate with a web server on the internet.
Show answer & marking scheme

Worked solution

(a) (i) A Wireless Access Point (WAP) is the hardware device that allows wireless devices to connect to a wired network using Wi-Fi standards.
(ii) A Router is the network device that connects different networks together, such as the company's LAN and the global internet, and forwards data packets between them.

(b) (i) A MAC (Media Access Control) address is a unique identifier assigned to a network interface controller (NIC) by the manufacturer. It acts as a permanent physical address to uniquely identify a device within a local network.
(ii) An IP address identifies the network location of a device, allowing routers to forward packets across the internet to the correct destination network. Once the packet arrives at the local network, the destination MAC address is used to deliver the packet to the exact physical machine.

Marking scheme

Part (a)(i) [1 mark]:
- 1 mark for Wireless Access Point // WAP // Access Point.

Part (a)(ii) [1 mark]:
- 1 mark for Router.

Part (b)(i) [2 marks max]:
- 1 mark for stating that it uniquely identifies a physical device on a network.
- 1 mark for stating that it is hardcoded/assigned by the manufacturer / does not change when the device moves networks.

Part (b)(ii) [2 marks max]:
- 1 mark for stating that the IP address is used for routing across networks / identifying the destination network.
- 1 mark for stating that the MAC address is used for physical identification / delivery within the local network.
Question 9 · structured
4 marks
A software engineering team is developing two different software systems:

- **System A**: A real-time engine management system for an electric vehicle, which requires direct manipulation of specific hardware registers and must have extremely low memory usage.
- **System B**: A cloud-based customer relationship management (CRM) platform that needs to be portable across different operating systems and must be developed rapidly by a large team of programmers.

State which type of programming language (high-level or low-level) is most appropriate for each system. Justify your choice in each case.

**System A**
Language type:
Justification:

**System B**
Language type:
Justification:
Show answer & marking scheme

Worked solution

For **System A**, a low-level language is ideal because it provides direct access to hardware registers and generates code that is highly memory-efficient, which is critical for real-time embedded systems. For **System B**, a high-level language is best because it is portable across multiple platforms and speeds up development and maintenance for large teams of developers.

Marking scheme

System A:
- 1 mark: Low-level language (Accept Assembly language / Machine code)
- 1 mark: Valid justification (e.g. direct access to registers/hardware, highly memory efficient, faster runtime execution)

System B:
- 1 mark: High-level language
- 1 mark: Valid justification (e.g. portable / platform-independent, faster/easier to write and debug, easier for team collaboration)
Question 10 · structured
10 marks
A school stores its student database on a network server. The administrator is concerned about cybersecurity threats, particularly ransomware and phishing. (a) State what is meant by ransomware and describe how it could affect the school's computer system. [3] (b) The school staff are trained to identify phishing attempts. Identify three indicators in an email that could suggest it is a phishing attempt. [3] (c) The administrator decides to use a firewall and encryption to protect the database. Explain how each of these solutions protects the school's network or data. Firewall [2] Encryption [2]
Show answer & marking scheme

Worked solution

(a) Ransomware is a type of malicious software (malware) that encrypts files on a victim's device or network, or locks them out of their system. The attacker then demands a ransom payment (often in cryptocurrency) in exchange for the decryption key to restore access. For a school, this would lock critical student records, stop online lessons, or lead to permanent data loss if backups are compromised. (b) Common indicators of phishing include: spelling and grammar mistakes; the sender address not matching the official domain name; generic greetings rather than personal names; urgent requests for credentials; and suspicious links or unexpected attachments. (c) A firewall operates at the network boundary, monitoring traffic and comparing it against predefined security rules to block unauthorized entry. Encryption translates the plain database files into ciphertext. Even if an attacker accesses or steals the data, they cannot comprehend it without the specific decryption key.

Marking scheme

(a) Maximum 3 marks: 1 mark for defining ransomware (malware that encrypts files / locks systems). 1 mark for describing the mechanism (demands a ransom payment for a decryption key / restoring access). 1 mark for describing the impact on the school (unable to access student files / disruption to school operations). (b) Maximum 3 marks: 1 mark per correct indicator identified (such as spelling errors, generic greeting, mismatched sender domain, urgent/threatening language, suspicious links/attachments). (c) Maximum 4 marks: Firewall (Max 2 marks): 1 mark for explaining traffic monitoring/filtering based on predefined rules. 1 mark for stating it prevents unauthorized access/malicious traffic from entering the network. Encryption (Max 2 marks): 1 mark for stating it scrambles/encodes data using an algorithm/key. 1 mark for explaining that intercepted data is unreadable/useless without the decryption key.
Question 11 · Robotics
5 marks
A pharmaceutical laboratory uses robots to transport and process highly toxic chemical samples. (a) A robot typically has a mechanical structure. Identify two other main characteristics that define a robot. [2] (b) State two benefits to the laboratory technicians of using these robots to handle the toxic chemical samples. [2] (c) State one financial or operational drawback to the laboratory management of deploying these robots. [1]
Show answer & marking scheme

Worked solution

(a) Robots are characterized by having a mechanical structure, electrical components to sense (sensors) and move (actuators), and digital systems to be programmable or autonomous. (b) Lab technicians benefit by avoiding dangerous hazards (chemical toxicity) and being freed from boring, repetitive physical labor to focus on interesting data analysis. (c) Laboratory owners suffer from massive upfront capital investment and the expensive configuration of precise robotic laboratory arms.

Marking scheme

Part (a): One mark per correct characteristic, up to a maximum of 2 marks. - Electrical/electronic components (e.g. sensors, actuators) - Programmable / controlled by a microprocessor / guided by software code - Can sense its environment - Can make autonomous decisions. Part (b): One mark per correct benefit, up to a maximum of 2 marks. - Improved physical safety / eliminates risk of direct exposure to toxic chemical samples - Technicians can focus on higher-skilled, less repetitive tasks (e.g. analysis, programming) - Less fatigue / repetitive physical strain. Note: Reject 'does not need to take breaks' as this is a benefit to management/owners, not technicians. Part (c): One mark for a valid drawback, up to a maximum of 1 mark. - High initial purchase, installation, and setup costs - Ongoing specialized maintenance or calibration costs - Staff retraining costs to operate/integrate the robots - Risk of workflow stoppage (downtime) if the robots malfunction.
Question 12 · written
14 marks
A user is shopping online using a web browser.

(a) Explain how the web browser uses the Domain Name System (DNS) to find and load the shopping website. [4]

(b) The online shopping website uses both session cookies and persistent cookies.
Describe how both types of cookies are used to provide a personalized user experience on this website. [6]

(c) The shopping website uses the HTTPS protocol.
Explain how the HTTPS protocol is used to secure the connection between the user's browser and the web server. [4]
Show answer & marking scheme

Worked solution

(a) 1. The user enters the website URL into the browser.
2. The browser sends the URL request to a DNS server.
3. The DNS server looks up the URL in its database to find the matching IP address.
4. The IP address is sent back to the browser (or queried further up the hierarchy if not found).
5. The browser uses the IP address to establish a connection and request the website files from the web server.

(b) Session Cookies:
- Stored temporarily in the computer's RAM / volatile memory.
- Automatically deleted when the browser window or tab is closed.
- Used to track active choices, such as keeping items in the shopping cart while browsing different pages of the store.
Persistent Cookies:
- Stored on the user's hard drive / SSD / non-volatile secondary storage.
- Remain on the system until a set expiration date is reached or they are manually deleted by the user.
- Used to store user preferences, auto-fill login details, and track browsing habits over multiple visits to suggest personalized products.

(c) 1. HTTPS utilizes encryption protocols (SSL/TLS) to establish a secure tunnel.
2. Data transmitted between the user's browser and the web server is encrypted (converted to ciphertext).
3. This prevents third parties from reading sensitive data (such as login credentials or credit card numbers) if intercepted.
4. It uses digital certificates to verify and authenticate the identity of the web server, ensuring the user is not communicating with a spoofed website.

Marking scheme

(a) Max 4 marks:
- 1 mark for: Browser sends URL / domain name to the DNS server.
- 1 mark for: DNS server searches its database / registry for the matching IP address.
- 1 mark for: DNS server returns the IP address to the web browser (accept: queries higher-level servers if not found).
- 1 mark for: Browser sends request for the webpage directly to the web server using the IP address.

(b) Max 6 marks:
- Session cookies:
- 1 mark for: Stored in RAM / temporary memory.
- 1 mark for: Deleted when browser is closed / temporary lifespan.
- 1 mark for: Example in context (e.g., maintaining items in a shopping basket).
- Persistent cookies:
- 1 mark for: Stored on hard drive / SSD / secondary storage.
- 1 mark for: Remain until expiry date / deleted by user.
- 1 mark for: Example in context (e.g., remembering login details / showing tailored product recommendations).

(c) Max 4 marks:
- 1 mark for: Uses SSL / TLS protocol.
- 1 mark for: Encrypts data during transmission (accept: converts data to ciphertext).
- 1 mark for: Prevents intercepted data from being read / understood without a decryption key.
- 1 mark for: Uses digital certificates to authenticate the website's identity (preventing phishing / spoofing).

Ready to test yourself?

Turn these notes into exam-style practice. Get unlimited AI questions on this topic with instant marking and explanations.

Practice This Topic

Paper 2 Algorithms, Programming and Logic

Answer all questions. Calculators are not permitted. Use pseudocode or program code for programming questions.
15 Question · 97 marks
Question 1 · matching
7 marks
The program development life cycle consists of several stages: Analysis, Design, Coding, and Testing.

Match each of the following descriptions (1 to 7) to its most appropriate program development life cycle stage.

**Descriptions:**
1. Identifying the user requirements and constraints of the problem.
2. Using pseudocode to represent the logic of a search algorithm.
3. Entering programming statements using high-level language syntax.
4. Running the software with extreme test data to check for errors.
5. Breaking down a complex system into smaller, manageable sub-systems (decomposition).
6. Drawing a structure diagram to show the hierarchy of sub-tasks.
7. Verifying that the final program meets all success criteria specified in the test plan.
Show answer & marking scheme

Worked solution

1. Analysis — Identifying user requirements is the initial step of the analysis stage to define what the system must do.
2. Design — Pseudocode is an algorithm design tool used to plan out the solution's logic before coding.
3. Coding — Writing the high-level language instructions translates the design into executable instructions.
4. Testing — Subjecting the written program to various classes of test data (normal, extreme, abnormal) to identify faults occurs during testing.
5. Analysis — Decomposition is performed during analysis to understand the problem components and requirements.
6. Design — Structure diagrams are visual tools used to design the hierarchy of modular sub-systems.
7. Testing — Assessing whether the software successfully behaves as expected under the criteria defined in the test plan is the core objective of the testing stage.

Marking scheme

Award 1 mark for each correct match (maximum of 7 marks):
- Description 1 matched with Analysis
- Description 2 matched with Design
- Description 3 matched with Coding
- Description 4 matched with Testing
- Description 5 matched with Analysis
- Description 6 matched with Design
- Description 7 matched with Testing
Question 2 · Multiple Choice
1 marks
Tick (\checkmark) one box to show the term used to identify the position of an individual data item inside a one-dimensional (1D) array.
  1. A.Element
  2. B.Index
  3. C.Data type
  4. D.Variable
Show answer & marking scheme

Worked solution

The correct answer is B. An index (or subscript) is used to specify the position of an element within an array, whereas 'Element' refers to the actual data item itself, 'Data type' refers to the format of the data, and 'Variable' is a generic named storage location.

Marking scheme

1 mark for the correct option:
- B / Index
Question 3 · Multiple Choice
1 marks
Tick (\checkmark) one box to show the term used to describe a single value stored inside an array.
  1. A.Element
  2. B.Index
  3. C.Dimension
  4. D.Constant
Show answer & marking scheme

Worked solution

The correct answer is A. An element represents an individual data item stored within an array structure.

Marking scheme

1 mark for the correct option:
- A / Element
Question 4 · written-response
8 marks
A booking system requires the user to enter the number of tickets they wish to buy. The input must be a whole number from 1 to 6 inclusive.

(a) Name and describe two different validation checks that should be performed on this input. [4]

(b) Choose one validation check from part (a). State one example of each of the following types of test data that would be used to test this validation check, and give a reason for your choice:

(i) Abnormal test data [2]

(ii) Extreme test data [2]
Show answer & marking scheme

Worked solution

(a) Suitable validation checks include:
- Range check: Ensures the input is between 1 and 6 inclusive. Any values below 1 or above 6 will be rejected.
- Type check: Ensures that the input is an integer (whole number) and not characters, words, or real numbers.
- Presence check: Ensures the user does not leave the field empty.

(b) Test data examples and reasons (using Range Check as the chosen check):
- (i) Abnormal test data: 0 (or 8, or 'ten'). This data is invalid and falls outside the expected range, so the system should reject it and display an error.
- (ii) Extreme test data: 1 (or 6). These are the boundary limits of the valid range. They are the minimum and maximum acceptable values and should be accepted by the system.

Marking scheme

Part (a):
- 1 mark for each validation check named (Max 2)
- 1 mark for each corresponding description applied to this scenario (Max 2)
- Allowed checks: Range check, Type check, Presence check.

Part (b)(i):
- 1 mark for correct abnormal test case (e.g., 0, 7, -1, 4.5, 'two') [1]
- 1 mark for a valid reason explaining that the data is invalid/wrong type/outside the range and should be rejected [1]

Part (b)(ii):
- 1 mark for correct extreme test case (must be 1 or 6) [1]
- 1 mark for a valid reason explaining that it is a boundary value at the edge of the range and should be accepted [1]
Question 5 · short-answer
4 marks
Explain the purpose of the pseudocode library routines `MOD` and `RANDOM`
Show answer & marking scheme

Worked solution

MOD:
- **Purpose**: Performs modulo division, which divides one integer by another and returns only the remainder.
- **Example**: `14 MOD 4` returns `2` because 4 goes into 14 three times with a remainder of 2.

RANDOM:
- **Purpose**: Generates and returns a pseudo-random real (fractional) number.
- **Range**: By default, it returns a value between 0 (inclusive) and 1 (exclusive).
- **Example**: `RANDOM()` could return `0.812`.

Marking scheme

One mark per mark point, max four

MOD, max two:
- To find the remainder of an integer division // to perform modulo division [1]
- Only the remainder part of the answer is retained/returned [1]
- Give a correct example of MOD, e.g., `14 MOD 4 = 2` [1]

RANDOM, max two:
- To generate / return a pseudo-random number [1]
- To return a real/fractional number in the range 0 to 1 (exclusive) [1]
- Give a correct example of RANDOM, e.g., `RANDOM() = 0.57` [1]
Question 6 · written
8 marks
An algorithm has been written in pseudocode to count how many negative numbers are input by a user. The user enters numbers one by one, and an input of -999 stops the algorithm.

01 Count ← 1
02 INPUT Value
03 WHILE Value = -999 DO
04 IF Value < 0
05 THEN
06 Count ← Count + Value
07 ENDIF
08 INPUT Value
09 ENDWHILE
10 OUTPUT "The total number of negative numbers is ", Value

Identify the four errors in the pseudocode and suggest a correction for each error.
Show answer & marking scheme

Worked solution

Error 1:
Identification: Line 01 incorrectly initialises the counter variable Count to 1.
Correction: Count ← 0

Error 2:
Identification: Line 03 has an incorrect loop condition which stops immediately unless the first entry is -999.
Correction: WHILE Value <> -999 DO

Error 3:
Identification: Line 06 incorrectly adds the input variable Value to Count instead of incrementing the count by 1.
Correction: Count ← Count + 1

Error 4:
Identification: Line 10 incorrectly outputs the variable Value (which will be the sentinel -999) instead of the Count.
Correction: OUTPUT "The total number of negative numbers is ", Count

Marking scheme

Award marks up to a maximum of 8:
- 1 mark for identifying each error (max 4)
- 1 mark for each corresponding correct correction (max 4)

Acceptable equivalent syntax for corrections (e.g., != instead of <>).
Question 7 · written
8 marks
An algorithm has been written in pseudocode to count how many negative numbers are input by a user. The user enters numbers one by one, and an input of -999 stops the algorithm.

01 Count ← 1
02 INPUT Value
03 WHILE Value = -999 DO
04 IF Value < 0
05 THEN
06 Count ← Count + Value
07 ENDIF
08 INPUT Value
09 ENDWHILE
10 OUTPUT "The total number of negative numbers is ", Value

Identify the four errors in the pseudocode and suggest a correction for each error.
Show answer & marking scheme

Worked solution

Error 1:
Identification: Line 01 incorrectly initialises the counter variable Count to 1.
Correction: Count ← 0

Error 2:
Identification: Line 03 has an incorrect loop condition which stops immediately unless the first entry is -999.
Correction: WHILE Value <> -999 DO

Error 3:
Identification: Line 06 incorrectly adds the input variable Value to Count instead of incrementing the count by 1.
Correction: Count ← Count + 1

Error 4:
Identification: Line 10 incorrectly outputs the variable Value (which will be the sentinel -999) instead of the Count.
Correction: OUTPUT "The total number of negative numbers is ", Count

Marking scheme

Award marks up to a maximum of 8:
- 1 mark for identifying each error (max 4)
- 1 mark for each corresponding correct correction (max 4)

Acceptable equivalent syntax for corrections (e.g., != instead of <>).
Question 8 · open-response
4 marks
A developer is tasking a junior programmer with improving the maintainability of a large software application. Describe two different programming practices that should be used to make the program easier to maintain. Explain how each practice helps when another programmer needs to update or fix the code in the future.
Show answer & marking scheme

Worked solution

To make a program more maintainable, a programmer can use several practices: 1. Use of meaningful identifier names: Naming variables, constants, and subroutines based on their function (e.g., TotalScore instead of x). This helps a programmer updating the code to instantly understand what data is stored in a variable, reducing the risk of introducing errors when modifying it. 2. Use of comments / internal documentation: Adding comments (e.g., using // or #) to explain complex logic or the purpose of a block of code. This helps other developers quickly comprehend why a specific method or algorithm was implemented, saving time during debugging or enhancement. 3. Consistent indentation and spacing: Aligning code blocks within loops, selections, and subroutines consistently. This makes the hierarchy and flow of control immediately visible, helping to spot missing end-statements or incorrectly nested blocks. 4. Modular structure (procedures/functions): Breaking down a large program into smaller, self-contained subroutines. This ensures code can be modified or fixed in one module without unintended side effects on other parts of the system, and individual modules can be tested independently.

Marking scheme

One mark for each correct practice described (max two) and one mark for each matching explanation (max two). Practice (Max 2 marks): - Meaningful identifier names // descriptive variable names - Internal documentation // commenting // annotations - Consistent indentation // use of blank lines // white space - Modular structure // use of procedures / functions // subroutines. Explanation (Max 2 marks): - (Descriptive names) makes it clear what data is stored or processed / reduces trace time. - (Comments) explain the purpose of complex logic or the overall algorithm, making the code quicker to understand. - (Indentation/white space) shows the structure / flow of selection and iteration blocks, helping to spot nesting errors. - (Modular design) allows separate sections of code to be modified, tested, and debugged independently / prevents side effects in other parts of the program. Note: Do not award marks for general debugging techniques like 'syntax checks' or 'dry runs'.
Question 9 · text
7 marks

An algorithm is represented by the following pseudocode. The 1D array Items[] contains six integers: [12, 7, 15, 4, 9, 14], indexed from 1 to 6.

Count ← 0
Sum ← 0
FOR Index ← 1 TO 6
  IF Items[Index] > 8 THEN
    Sum ← Sum + Items[Index]
    Count ← Count + 1
  ELSE
    Items[Index] ← Items[Index] * 2
  ENDIF
NEXT Index
Average ← Sum / Count
OUTPUT "Count is ", Count
OUTPUT "Average is ", Average

(a) Complete the trace table for this algorithm. [4]

IndexSumCountAverageOUTPUT     

(b) State the purpose of the algorithm. [2]

(c) State the final value stored in Items[2] after the algorithm has finished executing. [1]

Show answer & marking scheme

Worked solution

Let's trace the execution of the algorithm step-by-step:

  • Initially, Sum = 0 and Count = 0.
  • Index = 1: Items[1] = 12. Since 12 > 8 is true:
    • Sum = 0 + 12 = 12
    • Count = 0 + 1 = 1
  • Index = 2: Items[2] = 7. Since 7 > 8 is false:
    • Items[2] = 7 * 2 = 14
    • (Sum and Count remain unchanged)
  • Index = 3: Items[3] = 15. Since 15 > 8 is true:
    • Sum = 12 + 15 = 27
    • Count = 1 + 1 = 2
  • Index = 4: Items[4] = 4. Since 4 > 8 is false:
    • Items[4] = 4 * 2 = 8
    • (Sum and Count remain unchanged)
  • Index = 5: Items[5] = 9. Since 9 > 8 is true:
    • Sum = 27 + 9 = 36
    • Count = 2 + 1 = 3
  • Index = 6: Items[6] = 14. Since 14 > 8 is true:
    • Sum = 36 + 14 = 50
    • Count = 3 + 1 = 4
  • After exiting the loop:
    • Average = Sum / Count = 50 / 4 = 12.5
    • First Output: "Count is 4"
    • Second Output: "Average is 12.5"

Marking scheme

(a) Trace Table [4 marks]:
- 1 mark for correct Index sequence (1, 2, 3, 4, 5, 6)
- 1 mark for correct updates in the Sum column (12, 27, 36, 50)
- 1 mark for correct updates in the Count column (1, 2, 3, 4) and Average (12.5)
- 1 mark for correct OUTPUT values ("Count is 4" and "Average is 12.5")

(b) Purpose [2 marks]:
- 1 mark for stating that it counts and averages values in the array that are greater than 8
- 1 mark for stating that it doubles any values that are 8 or less

(c) Value of Items[2] [1 mark]:
- 1 mark for 14
Question 10 · Structured
5 marks
The string handling functions LENGTH, LCASE, UCASE and SUBSTRING are used in pseudocode.

(a) Write the pseudocode statements to:
• store the string "FR-2024-A" in the variable RegCode
• extract the first two characters of RegCode and store them in Country
• convert the string in Country to lowercase and output the result.
[3]

(b) The variable ProductCode has been stored:
ProductCode ← "SuperClean-99"

State the output that would be produced by the following pseudocode statements:
Size ← LENGTH(ProductCode)
Extract ← SUBSTRING(ProductCode, 6, 5)
OUTPUT Size
OUTPUT UCASE(Extract)
[2]
Show answer & marking scheme

Worked solution

Part (a):
RegCode ← "FR-2024-A" (Assigns string to variable)
Country ← SUBSTRING(RegCode, 1, 2) (Extracts 2 characters starting from index 1: "FR")
OUTPUT LCASE(Country) (Converts "FR" to "fr" and outputs it)

Part (b):
- LENGTH("SuperClean-99") calculates the number of characters in the string, which is 13 (including the hyphen and digits).
- SUBSTRING("SuperClean-99", 6, 5) extracts 5 characters starting at index 6 (where index 1 is 'S', 2 is 'u', 3 is 'p', 4 is 'e', 5 is 'r', and 6 is 'C'). This yields "Clean".
- OUTPUT Size outputs 13.
- OUTPUT UCASE(Extract) outputs the uppercase version of "Clean", which is CLEAN.

Marking scheme

Part (a) [Max 3 marks]:
- 1 mark: RegCode ← "FR-2024-A"
- 1 mark: Country ← SUBSTRING(RegCode, 1, 2) (allow index 0 if clearly indicated, but 1-based is standard)
- 1 mark: OUTPUT LCASE(Country) (or equivalent printing statement)

Part (b) [Max 2 marks]:
- 1 mark: 13
- 1 mark: CLEAN (must be in uppercase)
Question 11 · Logic gate schematic and truth table
8 marks
Consider this logic expression:

X = (A XOR B) OR (NOT B AND C)

(a) Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two inputs. Do not simplify this logic expression. [4]

(b) Complete the truth table from the given logic expression. [4]

| A | B | C | Working space | X |
|---|---|---|---|---|
| 0 | 0 | 0 | | |
| 0 | 0 | 1 | | |
| 0 | 1 | 0 | | |
| 0 | 1 | 1 | | |
| 1 | 0 | 0 | | |
| 1 | 0 | 1 | | |
| 1 | 1 | 0 | | |
| 1 | 1 | 1 | | |
Show answer & marking scheme

Worked solution

(a) Designing the circuit step-by-step:
1. First term: (A XOR B). Draw an XOR gate with inputs A and B.
2. Second term: (NOT B AND C). Draw a NOT gate on input B. Take the output of this NOT gate and input C into an AND gate.
3. Combining term: (A XOR B) OR (NOT B AND C). Take the outputs from the XOR gate and the AND gate and connect them to the inputs of an OR gate to give output X.

(b) Evaluating the truth table rows:
- A=0, B=0, C=0: (0 XOR 0) OR (NOT 0 AND 0) = 0 OR 0 = 0
- A=0, B=0, C=1: (0 XOR 0) OR (NOT 0 AND 1) = 0 OR 1 = 1
- A=0, B=1, C=0: (0 XOR 1) OR (NOT 1 AND 0) = 1 OR 0 = 1
- A=0, B=1, C=1: (0 XOR 1) OR (NOT 1 AND 1) = 1 OR 0 = 1
- A=1, B=0, C=0: (1 XOR 0) OR (NOT 0 AND 0) = 1 OR 0 = 1
- A=1, B=0, C=1: (1 XOR 0) OR (NOT 0 AND 1) = 1 OR 1 = 1
- A=1, B=1, C=0: (1 XOR 1) OR (NOT 1 AND 0) = 0 OR 0 = 0
- A=1, B=1, C=1: (1 XOR 1) OR (NOT 1 AND 1) = 0 OR 0 = 0

Marking scheme

(a) Logic Circuit [4 marks]:
- 1 mark for correct XOR gate with inputs A and B.
- 1 mark for correct NOT gate with input B.
- 1 mark for correct AND gate with inputs NOT B and C.
- 1 mark for correct OR gate with inputs from XOR and AND gates.

(b) Truth Table [4 marks]:
- 4 marks for 8 correct outputs.
- 3 marks for 6 or 7 correct outputs.
- 2 marks for 4 or 5 correct outputs.
- 1 mark for 2 or 3 correct outputs.
Question 12 · structured
8 marks
A database table called ClubMember stores information about members of a sports club.

MemberIDFullNameMembershipTypeMonthlyFeeLockerAssignedJoinDateMEM104Sarah JenkinsGold45.00YES12/03/2021MEM112David SmithSilver30.00NO05/06/2022MEM203Amelie DupontBronze15.00NO22/08/2022MEM215Raj PatelGold45.00YES14/11/2021MEM301Elena RostovaGold45.00NO01/02/2023MEM320Marcus AureliusSilver30.00YES15/05/2023

(a) Identify the database field that would be most appropriate to select as the primary key and explain why.

Field: .......................................................
Reason: .......................................................

(b) Identify the most suitable data type for each of the following database fields, chosen from this list:
- text
- character
- Boolean
- integer
- real
- date/time
Each data type must be different.

- MonthlyFee: .......................................................
- LockerAssigned: .......................................................

(c) Complete this structured query language (SQL) command to show the member ID, full name and monthly fee for all members with a Gold membership.

SELECT MemberID, ......................................................., .......................................................
....................................................... ClubMember
WHERE MembershipType = .......................................................;
Show answer & marking scheme

Worked solution

(a) Field: MemberID
Reason: This field uniquely identifies each member because every member has a unique ID (there are no duplicate values).

(b) MonthlyFee: real (stores decimal monetary values)
LockerAssigned: Boolean (stores yes/no or true/false values)

(c) SELECT MemberID, FullName, MonthlyFee
FROM ClubMember
WHERE MembershipType = 'Gold';

Marking scheme

(a) 1 mark for correct field name, 1 mark for correct reason.
- Field: MemberID [1]
- Reason: Uniquely identifies each record / contains unique values / no duplicates [1]

(b) 1 mark for each correct data type.
- MonthlyFee: real [1]
- LockerAssigned: Boolean [1]

(c) 1 mark for each correct blank [max 4]:
- Blank 1: FullName [1]
- Blank 2: MonthlyFee [1]
- Blank 3: FROM [1]
- Blank 4: 'Gold' (accept "Gold" or Gold) [1]
Question 13 · subjective
15 marks
A one-dimensional (1D) array Users[] contains the names of five fitness program participants. A two-dimensional (2D) array DailySteps[] is used to store the daily step count, recorded once a day, for each of the seven days of the week (Monday to Sunday) for each participant. A 1D array WeeklyTotal[] is used to store the total step count for the week for each participant. The position of any participant's data is the same in all three arrays. For example, if the participant 'Ali' is in index 3 of Users[], Ali's daily step counts are in row index 3 of DailySteps[], and Ali's weekly total is in index 3 of WeeklyTotal[]. Daily step counts must be integers from 0 to 50000 inclusive. Write a program that meets the following requirements: - input and validate the daily step counts for 5 participants for each of the 7 days of the week - calculate and store the total weekly step count for each participant - calculate the overall average daily step count for all participants combined across the entire week - convert each participant's total weekly steps into kilometres using the formula: Distance = Steps * 0.00075 - output each participant's name, their weekly total step count, and their weekly distance in kilometres - output the overall average daily step count for all participants combined. You must use pseudocode or program code and add comments to explain how your code works. You do not need to declare any arrays, variables or constants; you may assume that this has already been done. All inputs and outputs must contain suitable messages. All data output for distance and average steps must be rounded to two decimal places. You will need to initialise and populate the array Users[] with 5 names at the start of the program.
Show answer & marking scheme

Worked solution

// Initialising and populating the Users array
DECLARE Users : ARRAY[1:5] OF STRING
Users[1] <-- "Ali"
Users[2] <-- "Bina"
Users[3] <-- "Chloe"
Users[4] <-- "David"
Users[5] <-- "Elena"

// Declaring variables (optional as per instructions, but best practice)
DECLARE DailySteps : ARRAY[1:5, 1:7] OF INTEGER
DECLARE WeeklyTotal : ARRAY[1:5] OF INTEGER
DECLARE UserIndex, DayIndex : INTEGER
DECLARE StepInput : INTEGER
DECLARE GroupTotalSteps : INTEGER
DECLARE GroupAverageDaily : REAL
DECLARE WeeklyDistance : REAL

GroupTotalSteps <-- 0

// Nested loop to input and validate steps for each user on each day
FOR UserIndex <-- 1 TO 5
WeeklyTotal[UserIndex] <-- 0
FOR DayIndex <-- 1 TO 7
OUTPUT "Enter daily step count for ", Users[UserIndex], " on day ", DayIndex, ":"
INPUT StepInput
// Validation loop for steps between 0 and 50000 inclusive
WHILE StepInput < 0 OR StepInput > 50000 DO
OUTPUT "Invalid entry. Steps must be between 0 and 50000 inclusive. Re-enter:"
INPUT StepInput

ENDWHILE
DailySteps[UserIndex, DayIndex] <-- StepInput
WeeklyTotal[UserIndex] <-- WeeklyTotal[UserIndex] + StepInput
GroupTotalSteps <-- GroupTotalSteps + StepInput
NEXT DayIndex
NEXT UserIndex

// Calculate group daily average across all participants and days (5 users * 7 days = 35 entries)
GroupAverageDaily <-- ROUND(GroupTotalSteps / 35, 2)

// Output details for each participant
FOR UserIndex <-- 1 TO 5
// Convert steps to distance (1 step = 0.00075 km) and round to 2 d.p.
WeeklyDistance <-- ROUND(WeeklyTotal[UserIndex] * 0.00075, 2)
OUTPUT "------------------------------------------------"
OUTPUT "Participant: ", Users[UserIndex]
OUTPUT "Total Steps This Week: ", WeeklyTotal[UserIndex]
OUTPUT "Estimated Distance Covered: ", WeeklyDistance, " km"
NEXT UserIndex

// Output overall group statistics
OUTPUT "================================================"
OUTPUT "The group's overall average daily step count was: ", GroupAverageDaily

Marking scheme

AO2: Apply knowledge and understanding (Max 9 marks)
- 1-3 Marks: At least one programming technique used appropriately (e.g., basic input/output loop). Some data stored using variables.
- 4-6 Marks: Uses nested loops to access the 2D array coordinates properly. Implements basic validation logic. Calculates totals and distance conversion correctly.
- 7-9 Marks: Complete and correct array operations for both 1D and 2D arrays. Correct validation check (0 to 50000 inclusive) with an iterative re-input loop. Correctly calculates overall average (totalling / 35). Correct rounding to two decimal places on all designated real values.

AO3: Provide solutions to problems (Max 6 marks)
- 1-2 Marks: Code structure contains some logical order. Identifiers are basic, with minimal or no commenting.
- 3-4 Marks: Logical program flow with key calculations placed outside the main input loops. Most variables and arrays are named meaningfully. Some comments explaining key sections.
- 5-6 Marks: Full, clean logical sequence from initialization to final summary output. Detailed comments describing validation, array population, distance conversion, and rounding. Output displays are formatted clearly with contextual descriptive messages.
Question 14 · POST
12 marks
  1. B.How, in plain English, can one describe pre and post-increment (or decrement) operators in C/C++?
Show answer & marking scheme

Worked solution

en-US

Marking scheme

By 20 | 12 +
Question 15 · thought
1 marks
Can you explain why the post-increment operator (i++) is slower than the pre-increment operator (++i) in C++? Is this also true for modern compilers?
Show answer & marking scheme

Worked solution


To understand why the post-increment operator (i++) can be slower than the pre-increment operator (++i), we need to look at how each operator works under the hood, especially when applied to user-defined objects (like iterators in C++).



While the performance difference is virtually non-existent for modern compilers optimizing built-in types (like int), it can still be significant for complex user-defined types.





### 1. The Core Difference: How they work

To understand the performance difference, we must look at what each operator actually does. Let’s look at their typical C++ implementations for a custom class or iterator:

#### A. Pre-increment (++i)
The pre-increment operator increments the value of the object and then **returns a reference to itself**.

```cpp
// Pre-increment (returns by reference)
MyClass& MyClass::operator++() {
this->value += 1; // Increment the value
return *this; // Return the updated, current object
}
```
Because it returns a reference (MyClass&), no new object is created. It is fast and efficient.

#### B. Post-increment (i++)
The post-increment is more complex. It must increment the object, but **return the value of the object *before* it was incremented**. To do this, it must make a temporary copy of the object, increment the original object, and then return the copy **by value**.

```cpp
// Post-increment (returns by value)
MyClass MyClass::operator++(int) {
MyClass temp = *this; // 1. Copy the current state (costly!)
this->value += 1; // 2. Increment
return temp; // 3. Return the old state by value
}
```
This requires:
1. Creating a temporary copy (invoking a **copy constructor**).
2. Memory allocation/deallocation if the object manages resources.
3. Copying the temporary object to the calling scope upon return.

---

### 2. Is this still true for modern compilers?

**For Built-in Types (`int`, `float`, `pointer`, etc.):**
**No.** Modern compilers are highly optimizing. If you write `i++` instead of `++i` in a loop where the return value of the expression is not used (e.g., `for (int i = 0; i < 10; i++)`), the compiler will detect that the temporary copy is unused and optimize it away.

In this case, **`i++` and `++i` compile to the exact same machine code.**

**For User-defined Types (Iterators, Custom Classes):**
**Yes, it can still be true.** If you are using complex objects like Standard Library iterators (e.g., `std::map::iterator`, `std::vector::iterator`), the compiler *might* not always be able to optimize away the temporary object.

While modern compilers are great at **RVO (Return Value Optimization)** and inlining, there are scenarios where the compiler cannot prove that the copy constructor has no side-effects (like logging, allocation, or memory tracking). If the compiler cannot prove this, **it is legally bound to run the copy constructor**, resulting in a performance hit.

---

### Summary of Best Practices

* **Default to Pre-increment (`++i`):** Unless you specifically need the old value (e.g., `array[i++]`), always use `++i`. It is a good habit, ensuring you never suffer from accidental performance loss when switching to complex iterators or custom classes.
* **Modern C++:** For primitive types, use whichever you prefer; the compiler will optimize it. However, in generic programming (templates), using `++i` is highly recommended because the type of the variable is unknown and could be a heavy-duty iterator.

Marking scheme

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.

Want more questions like this? Practice unlimited on thinka, instant answers included.

Start Practicing Free