wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

pseudocode

Total questions: 60

Worksheet time: 30mins

Name
Class
Date
1.

Which pseudocode correctly finds the average of two numbers?

a)

INPUT a, b; SET avg = a + b / 2; DISPLAY avg.

b)

INPUT a, b; SET avg = (a + b) / 2; DISPLAY avg.

c)

INPUT a, b; SET avg = a + b; DISPLAY avg / 2.

2.

In a flowchart, what symbol represents a decision point?

a)

Rectangle

b)

Parallelogram

c)

Diamond

3.

Given: x = 5, y = 2, what is the result of x % y + x // y?

a)

3

b)

5

c)

2

d)

4

4.

Which of the following is a valid pseudocode assignment statement?

a)

SET total = num1 + num2.

b)

total = num1 + num2

c)

SET total: num1 + num2

5.

What will be displayed? SET a = 3; b = 2; DISPLAY a * b + b * 2

a)

8

b)

12

c)

10

6.

What type of error occurs when a program runs but gives the wrong output?

a)

Logical error.

b)

Syntax error.

c)

Runtime error.

d)

Compilation error.

7.

Which statement shows the proper order of operations in arithmetic expressions?

a)

A. Parentheses, Exponents, Multiplication/Division, Addition/Subtraction.

b)

B. Parentheses, Multiplication/Division, Exponents, Addition/Subtraction.

c)

C. Exponents, Parentheses, Multiplication/Division, Addition/Subtraction.

8.

Which of the following best describes structured programming?

a)

Using only loops to organize logic.

b)

Using sequence, selection, and looping to organize logic.

c)

Using only selection to organize logic.

9.

What is the output of this pseudocode? SET x = 10 SET y = 3 DISPLAY x DIV y

a)

3

b)

4

c)

2

d)

1

10.

What happens if a variable is used without initialization?

a)

Produces an unpredictable result.

b)

It will always produce zero.

c)

It will cause a syntax error.

d)

The program will not compile.

11.

Which flowchart symbol represents input/output?

a)

Rectangle

b)

Parallelogram

c)

Diamond

12.

What will be the output of this code? x = 3 y = 4 print(x ** 2 + y ** 2)

a)

7

b)

12

c)

25

13.

What does a compiler do?

a)

Translates source code into machine code.

b)

Executes machine code directly.

c)

Stores data in memory.

d)

Manages network connections.

14.

What is the main purpose of pseudocode?

a)

To plan program logic in human-readable steps.

b)

To execute code directly.

c)

To debug code.

15.

Which of the following illustrates selection control?

a)

FOR...NEXT loop

b)

WHILE...DO loop

c)

IF...THEN...ELSE structure.

16.

What is the output of this? SET n = 2 DISPLAY n * n + 1

a)

5

b)

3

c)

7

d)

4

17.

What is the main advantage of modular programming?

a)

Programs are faster to execute.

b)

Programs are easier to write from scratch.

c)

Programs are easier to debug and reuse.

18.

Which logical operator is used for 'not equal to'?

a)

==

b)

!=

c)

<=

19.

If condition A is True and B is False, what is the result of A AND B?

a)

True

b)

Cannot be determined

c)

False

20.

Flowcharts can show loops and conditions clearly.

a)

True

b)

False

21.

How many times will this loop execute? FOR i = 1 TO 4 DISPLAY i END FOR

a)

3 times

b)

4 times

c)

5 times

d)

1 time

22.

What will be the last value displayed? SET x = 0 WHILE x < 5 DISPLAY x x = x + 2 END WHILE

a)

A. 2

b)

B. 5

c)

C. 4

d)

D. 6

23.

What type of loop checks the condition before running the body?

a)

While loop.

b)

For loop.

c)

Do-while loop.

d)

Infinite loop.

24.

What is the output? SET count = 1 DO DISPLAY count count = count + 1 WHILE count <= 3

a)

1, 2

b)

1, 2, 3

c)

1, 2, 3, 4

d)

3, 2, 1

25.

Identify the logic error: SET n = 0 WHILE n < 5 DISPLAY n END WHILE

a)

Infinite loop

b)

Off-by-one error

c)

Missing update expression.

d)

Syntax error

26.

What will this code print? FOR i = 2 TO 6 STEP 2 DISPLAY i END FOR

a)

2, 4, 6

b)

2, 3, 4, 5, 6

c)

2, 4

d)

6, 4, 2

27.

What happens if the loop condition is always True?

a)

The loop never runs

b)

Infinite loop.

c)

The loop runs once

d)

The loop runs twice

28.

Which loop is best when the number of repetitions is unknown?

a)

For loop

b)

While loop.

c)

Do-while loop

d)

Nested loop

29.

What is the output? SET total = 0 FOR i = 1 TO 3 total = total + i END FOR DISPLAY total

a)

3

b)

4

c)

6

d)

5

30.

What type of loop should you use to validate user input until correct?

a)

For loop

b)

While loop

c)

Sentinel-controlled loop.

d)

Infinite loop

31.

Which of the following statements will stop the loop immediately?

a)

CONTINUE

b)

BREAK.

c)

EXIT

d)

STOP

32.

Which statement skips to the next iteration of the loop?

a)

BREAK

b)

EXIT

c)

CONTINUE.

d)

STOP

33.

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

a)

6 times

b)

3 times

c)

2 times

d)

5 times

34.

The loop control variable must always be updated inside the loop.

a)

True

b)

False

35.

The for loop is best for definite repetition.

a)

True

b)

False

36.

True or False: The do-while loop is a pre-test loop.

a)

True

b)

False

37.

A while loop might not execute at all.

a)

True

b)

False

38.

Nested loops can handle 2D data like tables.

a)

True

b)

False

39.

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

a)

2

b)

4

c)

6

d)

8

40.

Which part of the loop determines when to stop?

a)

The condition.

b)

The update

c)

The initialization

d)

The body

41.

What happens if the loop variable is initialized incorrectly?

a)

The loop will never run

b)

The loop will run forever

c)

The loop may run too few or too many times.

d)

The loop will always run once

42.

What is the result of this pseudocode? SET n = 1 WHILE n <= 4 DISPLAY n * 2 n = n + 1 END WHILE

a)

A – 2, 4, 6, 8.

b)

B – 1, 2, 3, 4.

c)

C – 2, 3, 4, 5.

43.

Which loop executes at least once even if condition is false?

a)

For loop.

b)

Do-While loop.

c)

While loop.

44.

Identify the error: FOR i = 1 TO 5 DISPLAY i i = i + 1 END FOR

a)

The loop variable is not initialized.

b)

The loop variable is not used.

c)

The loop variable is modified twice.

45.

Which of the following loops is most suitable for counting down?

a)

FOR i = 10 TO 1 STEP -1.

b)

FOR i = 1 TO 10 STEP 1.

c)

WHILE i > 0.

46.

What does this pseudocode display? SET A = [1, 2, 3] FOR i = 0 TO 2 DISPLAY A[i] END FOR

a)

A – 1, 2, 3.

b)

B – 0, 1, 2.

c)

C – 3, 2, 1.

47.

Which statement correctly accesses the second element of an array?

a)

A – A[0].

b)

B – A[1].

c)

C – A[2].

48.

If an array A has 4 elements, valid indices are:

a)

A – 1 to 4.

b)

B – 1 to 3.

c)

C – 0 to 3.

49.

What is the output? SET A = [2, 4, 6] DISPLAY A[0] + A[2]

a)

A – 6.

b)

B – 8.

c)

C – 10.

50.

What happens when trying to access an index beyond the array size?

a)

Returns 0.

b)

Out of bounds error.

c)

Returns last element.

51.

Which loop efficiently displays all elements in an array?

a)

FOR i = 0 TO length - 1.

b)

WHILE i < length.

c)

DO WHILE i < length.

52.

Arrays store multiple values of the same data type.

a)

True

b)

False

53.

The first element of an array is at index 1.

a)

True

b)

False

54.

Arrays and loops can be combined for data processing.

a)

True

b)

False

55.

A two-dimensional array can represent rows and columns.

a)

True

b)

False

56.

Structured programming helps avoid spaghetti code.

a)

True

b)

False

57.

Logical operators can combine multiple conditions.

a)

True

b)

False

58.

Variables can be reassigned new values during program execution.

a)

True

b)

False

59.

Constants can change during the program.

a)

True

b)

False

60.

The modulus operator (%) gives the remainder of division.

a)

True

b)

False