NEW
Font size
Worksheetspseudocode
Total questions: 60
Worksheet time: 30mins
Which pseudocode correctly finds the average of two numbers?
INPUT a, b; SET avg = a + b / 2; DISPLAY avg.
INPUT a, b; SET avg = (a + b) / 2; DISPLAY avg.
INPUT a, b; SET avg = a + b; DISPLAY avg / 2.
In a flowchart, what symbol represents a decision point?
Rectangle
Parallelogram
Diamond
Given: x = 5, y = 2, what is the result of x % y + x // y?
3
5
2
4
Which of the following is a valid pseudocode assignment statement?
SET total = num1 + num2.
total = num1 + num2
SET total: num1 + num2
What will be displayed? SET a = 3; b = 2; DISPLAY a * b + b * 2
8
12
10
What type of error occurs when a program runs but gives the wrong output?
Logical error.
Syntax error.
Runtime error.
Compilation error.
Which statement shows the proper order of operations in arithmetic expressions?
A. Parentheses, Exponents, Multiplication/Division, Addition/Subtraction.
B. Parentheses, Multiplication/Division, Exponents, Addition/Subtraction.
C. Exponents, Parentheses, Multiplication/Division, Addition/Subtraction.
Which of the following best describes structured programming?
Using only loops to organize logic.
Using sequence, selection, and looping to organize logic.
Using only selection to organize logic.
What is the output of this pseudocode? SET x = 10 SET y = 3 DISPLAY x DIV y
3
4
2
1
What happens if a variable is used without initialization?
Produces an unpredictable result.
It will always produce zero.
It will cause a syntax error.
The program will not compile.
Which flowchart symbol represents input/output?
Rectangle
Parallelogram
Diamond
What will be the output of this code? x = 3 y = 4 print(x ** 2 + y ** 2)
7
12
25
What does a compiler do?
Translates source code into machine code.
Executes machine code directly.
Stores data in memory.
Manages network connections.
What is the main purpose of pseudocode?
To plan program logic in human-readable steps.
To execute code directly.
To debug code.
Which of the following illustrates selection control?
FOR...NEXT loop
WHILE...DO loop
IF...THEN...ELSE structure.
What is the output of this? SET n = 2 DISPLAY n * n + 1
5
3
7
4
What is the main advantage of modular programming?
Programs are faster to execute.
Programs are easier to write from scratch.
Programs are easier to debug and reuse.
Which logical operator is used for 'not equal to'?
==
!=
<=
If condition A is True and B is False, what is the result of A AND B?
True
Cannot be determined
False
Flowcharts can show loops and conditions clearly.
True
False
How many times will this loop execute? FOR i = 1 TO 4 DISPLAY i END FOR
3 times
4 times
5 times
1 time
What will be the last value displayed? SET x = 0 WHILE x < 5 DISPLAY x x = x + 2 END WHILE
A. 2
B. 5
C. 4
D. 6
What type of loop checks the condition before running the body?
While loop.
For loop.
Do-while loop.
Infinite loop.
What is the output? SET count = 1 DO DISPLAY count count = count + 1 WHILE count <= 3
1, 2
1, 2, 3
1, 2, 3, 4
3, 2, 1
Identify the logic error: SET n = 0 WHILE n < 5 DISPLAY n END WHILE
Infinite loop
Off-by-one error
Missing update expression.
Syntax error
What will this code print? FOR i = 2 TO 6 STEP 2 DISPLAY i END FOR
2, 4, 6
2, 3, 4, 5, 6
2, 4
6, 4, 2
What happens if the loop condition is always True?
The loop never runs
Infinite loop.
The loop runs once
The loop runs twice
Which loop is best when the number of repetitions is unknown?
For loop
While loop.
Do-while loop
Nested loop
What is the output? SET total = 0 FOR i = 1 TO 3 total = total + i END FOR DISPLAY total
3
4
6
5
What type of loop should you use to validate user input until correct?
For loop
While loop
Sentinel-controlled loop.
Infinite loop
Which of the following statements will stop the loop immediately?
CONTINUE
BREAK.
EXIT
STOP
Which statement skips to the next iteration of the loop?
BREAK
EXIT
CONTINUE.
STOP
How many times will the inner loop run? FOR i = 1 TO 3 FOR j = 1 TO 2 DISPLAY i, j END FOR END FOR
6 times
3 times
2 times
5 times
The loop control variable must always be updated inside the loop.
True
False
The for loop is best for definite repetition.
True
False
True or False: The do-while loop is a pre-test loop.
True
False
A while loop might not execute at all.
True
False
Nested loops can handle 2D data like tables.
True
False
What is the output? SET sum = 0 FOR i = 1 TO 4 IF i % 2 == 0 THEN sum = sum + i END IF END FOR DISPLAY sum
2
4
6
8
Which part of the loop determines when to stop?
The condition.
The update
The initialization
The body
What happens if the loop variable is initialized incorrectly?
The loop will never run
The loop will run forever
The loop may run too few or too many times.
The loop will always run once
What is the result of this pseudocode? SET n = 1 WHILE n <= 4 DISPLAY n * 2 n = n + 1 END WHILE
A – 2, 4, 6, 8.
B – 1, 2, 3, 4.
C – 2, 3, 4, 5.
Which loop executes at least once even if condition is false?
For loop.
Do-While loop.
While loop.
Identify the error: FOR i = 1 TO 5 DISPLAY i i = i + 1 END FOR
The loop variable is not initialized.
The loop variable is not used.
The loop variable is modified twice.
Which of the following loops is most suitable for counting down?
FOR i = 10 TO 1 STEP -1.
FOR i = 1 TO 10 STEP 1.
WHILE i > 0.
What does this pseudocode display? SET A = [1, 2, 3] FOR i = 0 TO 2 DISPLAY A[i] END FOR
A – 1, 2, 3.
B – 0, 1, 2.
C – 3, 2, 1.
Which statement correctly accesses the second element of an array?
A – A[0].
B – A[1].
C – A[2].
If an array A has 4 elements, valid indices are:
A – 1 to 4.
B – 1 to 3.
C – 0 to 3.
What is the output? SET A = [2, 4, 6] DISPLAY A[0] + A[2]
A – 6.
B – 8.
C – 10.
What happens when trying to access an index beyond the array size?
Returns 0.
Out of bounds error.
Returns last element.
Which loop efficiently displays all elements in an array?
FOR i = 0 TO length - 1.
WHILE i < length.
DO WHILE i < length.
Arrays store multiple values of the same data type.
True
False
The first element of an array is at index 1.
True
False
Arrays and loops can be combined for data processing.
True
False
A two-dimensional array can represent rows and columns.
True
False
Structured programming helps avoid spaghetti code.
True
False
Logical operators can combine multiple conditions.
True
False
Variables can be reassigned new values during program execution.
True
False
Constants can change during the program.
True
False
The modulus operator (%) gives the remainder of division.
True
False
