Form 2 Asas Sains Komputer (ASK) comes down to two habits: tracing a short program to find what it prints, and choosing test inputs that reveal what the program forgets. This page teaches both with two small original programs on paper.
It sits inside the subject guides and is written for pupils whose school offers ASK in Form 2 under KSSM. It is not an offer for new Form 1 pupils in 2027, and it is a different subject from Form 4 Computer Science, so your school’s timetable and scheme of work decide what your class covers.
How do I trace a program line by line?
Trace means to act as the computer: take one input, run each line in order and write down every value that changes. Here is an original canteen program. The pseudocode keywords are only one style, and your textbook may use other words.
INPUT price
INPUT member
IF member = "Y" THEN
price ← price − 2
END IF
IF price > 10 THEN
PRINT "Pay by e-wallet"
ELSE
PRINT "Pay cash"
END IF
PRINT price
Try price 12 with member “Y”. The first IF is true, so price becomes 10. The second IF asks 10 > 10, which is false, so the program prints “Pay cash” and then 10.
| price in | member in | price after the first IF | output |
|---|---|---|---|
| 12 | Y | 10 | Pay cash, 10 |
| 12 | N | 12 | Pay by e-wallet, 12 |
| 11 | Y | 9 | Pay cash, 9 |
What is the usual tracing mistake?
The usual mistake is to answer the second IF with the original price of 12 and print “Pay by e-wallet” for the first row. That is wrong because line 4 already changed price to 10, and every later line uses the current value, not the starting value. A column that records price after each change prevents it.
How do I choose test inputs that expose a missing branch?
A test input is a value you choose before running the program, together with the output you expect. Here is a second original program for ticket types, meant to give Child under 13, Adult from 13 to 59 and Senior from 60.
INPUT age
IF age < 13 THEN
PRINT "Child ticket"
ELSE IF age >= 60 THEN
PRINT "Senior ticket"
END IF
Ages 5, 8 and 10 all print “Child ticket”, which looks correct, but they test one branch three times. Age 30 prints nothing, so the Adult branch is missing. Add the boundaries 12, 13, 59 and 60 as well.
A good set is 5, 12, 13, 30, 59, 60 and 70. The fix is an ELSE that prints “Adult ticket” for every age that fits neither condition.
Where should I go next?
Do the eight questions in Form 2 Asas Sains Komputer practice with fresh programs. Then read the Form 3 guide for comparing searches and correcting a logic error, and see the Form 2 overview for your other subjects.
Computer room work and any tool your school uses stay with the school. These pages train the paper skills that make that work easier.
If tracing a program by hand still leaves you unsure what it prints, Asas Sains Komputer tuition pairs you with a teacher who walks through the variable values step by step until you can do it silently.