1.
Declaration and Assignment of Variables
1. Write pseudocode to declare variables for:
o student name
o age
o average mark
2. Write pseudocode to:
o store the value 15 in a variable called Counter
o increase it by 5
o display the final value
3. A shop sells pens at RM2 each.
Write pseudocode to:
o input quantity
o calculate total cost
o display total
4. Identify and correct the errors:
INTEGER Name
Name ← "Ali"
OUTPUT name
5. Write pseudocode to swap the values of two variables.
2. User Input
1. Write pseudocode to input:
o username
o password
o age
2. Write pseudocode to:
o input 3 numbers
o display their sum
3. Write pseudocode to input temperature in Celsius and convert it to Fahrenheit.
4. Write pseudocode to input length and width of a rectangle and display area.
5. Write pseudocode to input a student’s mark and display:
"Pass" if mark is 50 or above.
3. Output Statements
1. Write pseudocode to display:
Welcome to Cambridge 0478
2. Write pseudocode to display a student’s name and score in one line.
3. Write pseudocode to display:
Total = 250
using variables.
4. Write pseudocode to output the result of:
25 + 14
5. Write pseudocode to display a formatted receipt with:
o item name
o quantity
o total price
4. Variable Assignment
1. Trace the following pseudocode:
X←5
Y←X+3
X←Y-2
OUTPUT X
OUTPUT Y
2. Write pseudocode to:
o assign 100 to Balance
o subtract 25
o display updated balance
3. What is the output?
A ← 10
B←A*2
A←B+5
OUTPUT A
OUTPUT B
4. Write pseudocode to calculate average of 4 marks.
5. Correct the logical error:
Total = Total + Number
5. Selection Statements
1. Write pseudocode to:
o input age
o display "Adult" if age ≥ 18
o otherwise display "Minor"
2. Write pseudocode for:
IF mark >= 80 THEN
OUTPUT "A"
ELSE
OUTPUT "Not A"
ENDIF
3. Write pseudocode to check whether a number is even or odd.
4. Write pseudocode to:
o input password
o display "Access Granted" if password is "CS0478"
5. Write pseudocode using nested IF statements to grade:
o A: 80+
o B: 60–79
o C: below 60
6. Trace the output:
Num ← 12
IF Num MOD 2 = 0 THEN
OUTPUT "Even"
ELSE
OUTPUT "Odd"
ENDIF
6. Iteration Statements – FOR and WHILE
1. Write pseudocode using a FOR loop to display numbers 1 to 10.
2. Write pseudocode using a WHILE loop to display numbers 10 down to 1.
3. Write pseudocode to:
o input 5 marks
o calculate total using a loop
4. Write pseudocode to display multiplication table of 7.
5. Trace the output:
FOR Count ← 1 TO 3
OUTPUT Count
NEXT Count
6. Write pseudocode to repeatedly ask for a password until correct.
7. Write pseudocode to count how many even numbers are entered in 10 inputs.
7. Subroutines – Procedures and Functions
1. Write a procedure called Greeting that displays:
Welcome Student
2. Write pseudocode for a function Square(Number) that returns the square.
3. Write pseudocode to call a procedure named DisplayMenu.
4. Write pseudocode for a function that calculates area of a rectangle.
5. Identify and justify whether the following is a procedure or function:
FUNCTION Add(X,Y)
RETURN X + Y
ENDFUNCTION
6. Write pseudocode with:
o a procedure to input marks
o a function to calculate average
7. Trace:
FUNCTION Double(X)
RETURN X * 2
ENDFUNCTION
OUTPUT Double(4)
8. Lists and Arrays
1. Declare an array called Names with 5 elements.
2. Write pseudocode to:
o store 5 marks in an array
o display all marks
3. Write pseudocode to find the highest value in an array.
4. Write pseudocode to calculate total of array elements.
5. Trace:
Nums[1] ← 5
Nums[2] ← 8
Nums[3] ← 2
OUTPUT Nums[2]
6. Write pseudocode to search for a name in an array.
7. Write pseudocode to count how many array values are greater than 50.
9. File Handling
1. Write pseudocode to open a file called "[Link]" for reading.
2. Write pseudocode to:
o input a student name
o write it into a file
3. Write pseudocode to read and display all lines from a file.
4. Identify the purpose of:
OPENFILE "[Link]" FOR APPEND
5. Write pseudocode to:
o read marks from a file
o calculate total marks
6. Explain the difference between:
o WRITE mode
o APPEND mode
7. Correct the error:
READFILE StudentName
10. 2D Arrays
1. Declare a 2D array called Marks with:
o 3 rows
o 4 columns
2. Write pseudocode to:
o input marks for 3 students and 4 subjects
o store them in a 2D array
3. Write pseudocode to display all values in a 2D array.
4. Write pseudocode to calculate total marks for each student.
5. Trace:
Marks[1,1] ← 10
Marks[1,2] ← 20
Marks[2,1] ← 30
OUTPUT Marks[1,2]
6. Write pseudocode to find the highest value in a 2D array.
7. Write pseudocode to calculate average marks for each column (subject).