cameroon gce advanced level June 2026 computer science 3 full solution

cameroon gce advanced level June 2026 computer science 3 full solution

cameroon gce advanced level June 2026 computer science 3 full solution

AL 2026 Computer Science Paper 3 Correction: Full Solutions with SQL, Pseudocode and C Code

Paper 3 of Advanced Level Computer Science (0795) is the practical paper. It rewards precision. You either write the SQL that runs, or you do not. You either trace the loop correctly, or your final answer is wrong.

This correction works through the June 2026 paper task by task. Section A covers database design for Nina’s Shop: normalisation, the ER diagram, and every SQL command. Section B covers the population-growth program: hand traces, pseudocode, the complete C implementation, and the expected screen output.

Read each task, attempt it yourself first, then compare. That is how corrections build marks.

Section A: Database — Nina’s Shop

The paper gives one unnormalised relation:

R(CustomerID, CustomerName, ItemCode, ItemName, UnitPrice, Quantity, TotalPrice, PDate)

This single table stores customer data, item data and purchase data together. That creates redundancy. Customer names repeat on every purchase, and item details repeat whenever the same item is bought again.

Task 1(i): Normalise to Second Normal Form

The original relation contains partial dependencies. CustomerName depends only on CustomerID. ItemName and UnitPrice depend only on ItemCode. Quantity, TotalPrice and PDate describe the purchase itself. So the relation splits into three:

Relation Attributes Primary Key Foreign Key
Customer CustomerID, CustomerName CustomerID None
Item ItemCode, ItemName, UnitPrice ItemCode None
Customer_Item CustomerID, ItemCode, PDate, Quantity, TotalPrice CustomerID + ItemCode + PDate CustomerID references Customer; ItemCode references Item

The composite key (CustomerID, ItemCode, PDate) is the right choice, because one customer can buy the same item on different dates.

Task 1(ii): Entity Relationship Diagram

+-------------------+          +-----------------------+          +----------------+
|     Customer      |          |     Customer_Item     |          |      Item      |
+-------------------+          +-----------------------+          +----------------+
| PK CustomerID     | 1      M | PK/FK CustomerID      | M      1 | PK ItemCode    |
| CustomerName      |----------| PK/FK ItemCode        |----------| ItemName       |
+-------------------+          | PK PDate              |          | UnitPrice      |
                               | Quantity              |          +----------------+
                               | TotalPrice            |
                               +-----------------------+

One customer buys many items, and one item is bought by many customers. That many-to-many relationship is resolved by the associative table Customer_Item.

Task 2(i): Create the database

CREATE DATABASE NinasShopDB;
USE NinasShopDB;

Task 2(ii): Create the tables

CREATE TABLE Customer (
    CustomerID VARCHAR(5) PRIMARY KEY,
    CustomerName VARCHAR(50) NOT NULL
);

CREATE TABLE Item (
    ItemCode VARCHAR(5) PRIMARY KEY,
    ItemName VARCHAR(30) NOT NULL,
    UnitPrice DECIMAL(10,2) NOT NULL
);

CREATE TABLE Customer_Item (
    CustomerID VARCHAR(5),
    ItemCode VARCHAR(5),
    PDate DATE,
    Quantity INT NOT NULL,
    TotalPrice DECIMAL(10,2) NOT NULL,

    PRIMARY KEY (CustomerID, ItemCode, PDate),
    FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID),
    FOREIGN KEY (ItemCode) REFERENCES Item(ItemCode)
);

Task 2(iii): Insert the records

INSERT INTO Customer (CustomerID, CustomerName)
VALUES
('C001', 'Effon Paul'),
('C002', 'Etta Enuni'),
('C003', 'Eyen Esther');

INSERT INTO Item (ItemCode, ItemName, UnitPrice)
VALUES
('IT001', 'Rice', 200),
('IT002', 'Beans', 250),
('IT003', 'Corn', 175);

INSERT INTO Customer_Item
(CustomerID, ItemCode, PDate, Quantity, TotalPrice)
VALUES
('C001', 'IT001', '2021-09-09', 3, 600),
('C001', 'IT002', '2021-09-09', 2, 500),
('C002', 'IT003', '2021-10-10', 2, 350),
('C003', 'IT003', '2021-12-17', 5, 875);

Task 2(iv): Rename Quantity to Qty

ALTER TABLE Customer_Item
RENAME COLUMN Quantity TO Qty;

Older MySQL versions use this form instead:

ALTER TABLE Customer_Item
CHANGE Quantity Qty INT NOT NULL;

Task 3(i): Update the price of Corn to 200

UPDATE Item
SET UnitPrice = 200
WHERE ItemName = 'Corn';

UPDATE Customer_Item AS CI
JOIN Item AS I
ON CI.ItemCode = I.ItemCode
SET CI.TotalPrice = CI.Qty * I.UnitPrice
WHERE I.ItemName = 'Corn';

Note the second statement. Changing the unit price alone leaves the stored TotalPrice values stale, so the purchase totals must be recalculated too.

Task 3(ii): Delete the tables

DROP TABLE Customer_Item;
DROP TABLE Item;
DROP TABLE Customer;

Order matters here. Customer_Item holds the foreign keys, so it must be dropped first. Dropping a parent table while a child still references it raises a constraint error.

Task 3(iii): Retrieve all customers who bought Beans

SELECT
    C.CustomerName,
    CI.Qty,
    CI.TotalPrice
FROM Customer AS C
JOIN Customer_Item AS CI
ON C.CustomerID = CI.CustomerID
JOIN Item AS I
ON CI.ItemCode = I.ItemCode
WHERE I.ItemName = 'Beans';

Expected output:

+--------------+-----+------------+
| CustomerName | Qty | TotalPrice |
+--------------+-----+------------+
| Effon Paul   |   2 |     500.00 |
+--------------+-----+------------+

Section B: Programming — Population Growth

The population model adds births and subtracts deaths each year. Integer division applies throughout, so fractional cows are discarded:

new_population = current_population + current_population // 3 - current_population // 4

Task 4(i)(a): From 1200 to 1300

Start population = 1200
Births = 1200 / 3 = 400
Deaths = 1200 / 4 = 300
New population = 1200 + 400 - 300 = 1300

Answer: 1 year.

Task 4(i)(b): From 27 to at least 37

Year Start population Births n/3 Deaths n/4 New population
1 27 9 6 30
2 30 10 7 33
3 33 11 8 36
4 36 12 9 39

Answer: 4 years.

Task 4(ii): A herd of 4 cows with no births

Start population = 4
Deaths = 4 / 4 = 1
New population = 4 - 1 = 3

Then deaths = 3 / 4 = 0 under integer division.

Answer: the population never reaches zero. It falls to 3 and stays at 3, because integer division of 3 by 4 gives 0 deaths.

Task 5(i): Pseudocode for InputStartSize

FUNCTION InputStartSize()
    DO
        DISPLAY "Start size: "
        INPUT start_size

        IF start_size < 9 THEN
            DISPLAY "Start size must be at least 9."
        END IF
    WHILE start_size < 9

    RETURN start_size
END FUNCTION

Task 5(ii): Pseudocode for CalculateYears

FUNCTION CalculateYears(start_size, end_size)
    years <- 0

    WHILE start_size < end_size DO
        births <- start_size DIV 3
        deaths <- start_size DIV 4
        start_size <- start_size + births - deaths
        years <- years + 1
    END WHILE

    RETURN years
END FUNCTION

Task 6: Complete C program

#include <stdio.h>

int InputStartSize(void)
{
    int start_size;

    do
    {
        printf("Start size: ");
        scanf("%d", &start_size);

        if (start_size < 9)
        {
            printf("Start size must be at least 9.n");
        }
    } while (start_size < 9);

    return start_size;
}

int InputEndSize(int minimum_size)
{
    int end_size;

    do
    {
        printf("End size: ");
        scanf("%d", &end_size);

        if (end_size < minimum_size)
        {
            printf("End size must be at least %d.n", minimum_size);
        }
    } while (end_size < minimum_size);

    return end_size;
}

int CalculateYears(int start_size, int end_size)
{
    int years = 0;

    while (start_size < end_size)
    {
        int births = start_size / 3;
        int deaths = start_size / 4;

        start_size = start_size + births - deaths;
        years++;
    }

    return years;
}

int main(void)
{
    int start_size;
    int end_size;
    int years;

    start_size = InputStartSize();
    end_size = InputEndSize(start_size);
    years = CalculateYears(start_size, end_size);

    printf("Years: %dn", years);

    return 0;
}

How the program works

  • InputStartSize keeps asking until the starting population is at least 9. Below 9, integer division stops deaths from reducing the herd properly.
  • InputEndSize keeps asking until the target is at least the starting population, which blocks an invalid end size.
  • CalculateYears applies births = start_size / 3 and deaths = start_size / 4 in a loop, stopping once the population reaches the target.

Task 7(a): Sample run

Start size: 5
Start size must be at least 9.
Start size: 3
Start size must be at least 9.
Start size: 9
End size: 5
End size must be at least 9.
End size: 18
Years: 8
Year Population
0 9
1 10
2 11
3 12
4 13
5 14
6 15
7 16
8 18

Task 7(b): Sample run

Start size: 20
End size: 18
End size must be at least 20.
End size: 10
End size must be at least 20.
End size: 100
Years: 20

The inputs 18 and 10 are both rejected, because each is smaller than the accepted starting population of 20. The program then accepts 100 and reports 20 years.

Final Summary of Answers

Question Final answer
4(i)(a) 1 year
4(i)(b) 4 years
4(ii) The population never becomes zero under integer division. It becomes 3 and remains 3.
7(a) Years: 8
7(b) Years: 20

Where Candidates Lose Marks

  • Forgetting the second UPDATE. Changing UnitPrice without recalculating TotalPrice leaves the data inconsistent.
  • Dropping tables in the wrong order. The child table holding foreign keys goes first.
  • Ignoring integer division. Using 27/4 = 6.75 instead of 6 throws off every row of the trace.
  • Omitting the composite key. CustomerID alone cannot identify a purchase, because the same customer buys on several dates.
  • Skipping input validation. Tasks 5 and 6 award marks specifically for the do-while loops that reject invalid input.

📥 Unlock More Computer Science Papers & Study Tools

📱 Download More Questions on the Kawlo App: Get the full Computer Science question bank with step-by-step corrections for Papers 1, 2 and 3. Download the Kawlo App from your mobile app store and practise interactive quizzes on your phone.

🌐 Access Extra Resources on gcerevision: For free downloadable PDF past papers, marking schemes and organised subject notes across O Level, A Level and Technical GCE, visit gcerevision and supercharge your revision today.

[//docs.google.com/gview?embedded=true&url=https://cameroongcerevision.com/wp-content/uploads/2026/08/AL_2026_CSC_3_Final_Solution.pdf]

Download: AL 2026 Computer Science Paper 3 — Full Solution (PDF)

Looking for solutions to this question? Contact us on WhatsApp on +237693670900

Leave a comment

Your email address will not be published. Required fields are marked *

sponsors Ads