Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

pseudocode

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

If a grade of 98 was inputted, what would be the output?

a)

Passed

b)

Failed

c)

Else

2.

If the grade of 60 was input, what would be the output?

a)

Passed

b)

Failed

c)

Else

3.

If the grade of 12 was input, what would be the output?

a)

Passed

b)

Failed

c)

Else

4.

What would the program output with the following inputs?

Payrate - 12

Hours Worked - 10

a)

12

b)

Final pay

c)

OUTPUT

d)

120

5.

Fill in the first blank

a)

Larger

b)

IF

c)

THEN

d)

WHILE

6.

What happens when the grade counter reaches 10.


Remember: <= means less than or equal to

a)

We add 1 to the grade counter

b)

The while loop keeps going

c)

We output out the average

d)

We end the while loop

7.

What happens when the grade counter reaches 11.


Remember: <= means less than or equal to

a)

We add 1 to the grade counter

b)

The while loop keeps going

c)

We output out the average

d)

We end the while loop

8.

Which type of iteration should be used when you know how many times you want to loop?

a)

Count Controlled

b)

Condition Controlled

9.

Which type of iteration should you use if you don't know how many times you need to loop?

a)

Condition Controlled

b)

Count Controlled

10.

What is missing?


____ i = 1 To 10

OUTPUT: "String"

ENDFOR

a)

FOR

b)

FOUR

c)

WHILE

11.

Fill in the missing blank:


_______ variable <> "Hi"

OUTPUT: "Hi to you!"

ENDWHILE

a)

WHILST

b)

WHILE

c)

FOR

d)

IF

12.

Pick the correct answer to match the following:


A loop that will check the condition before the code inside is executed.

a)

FOR

b)

WHILE

c)

REPEAT...UNTIL

13.

Pick the correct answer to match the following:


A loop that will check the condition after the code inside is executed.

a)

WHILE

b)

REPEAT...UNTIL

c)

FOR

14.

Which of the following will run 10 times? (Choose all that apply.)

a)

FOR i = 1 TO 10

OUTPUT: "Number " + i

ENDFOR

b)

FOR i = 0 To 10

OUTPUT: "Number: " + i

ENDFOR

c)

input = 10

count = 1

WHILE count <= input

OUTPUT: count

count = count + 1

ENDWHILE

15.

Complete the blank:


" (a)   is the process of repeating an action multiple times."

16.

Which of these is the correct syntax? (Choose all that apply.)

a)

FOR i = 1 TO 10

b)

WHILE i != 10

c)

FOR i = 1 <- 10

d)

WHILE i <> 10

17.

How many times will the following loop run?


myString = "A word"


FOR i = 1 TO LENGTH(myString)

'Do something

ENDFOR

a)

6

b)

5

c)

10

18.

What will be the output of the following pseudocode?


Integer i

Set i = 3

do

print i + 3

i = i - 1

while(i not equals 0)

end while

a)

5 5 5

b)

Infinite loop

c)

6 6 5

d)

6 5 4

19.

What would be the output of the following pseudocode?


Integer a

String str1

Set str1 = “goose”

a = stringLength(str1)

Print (a ^ 1)


Note: ^ is XOR operator

a)

5

b)

3

c)

4

d)

0

20.

What would be the output of the following pseudocode?


Integer i, j, k

Set k = 8

for(each i from 1 to 1)

for(each j from the value of i to 1)

print k+1

end for

end for

a)

8

b)

7

c)

9

d)

2

21.

What will be the output of the following pseudocode?


Integer a, b

Set a = 15, b = 7

a = a mod (a - 3)

b = b mod (b – 3)

a = a mod 1

b = b mod 1

Print a + b

a)

0

b)

2

c)

7

d)

15

22.

What will be the output of the following pseudocode?

Integer a, b, c

Set b = 5, a = 2, c = 2

if(b>a && a>c && c>b)

b = a + 1

Else

a = b + 1

End if

Print a + b + c

a)

5

b)

26

c)

13

d)

2

23.

If you are using a Depth-first search (DFS) for traversing an unweighted graph, then which of the following will happen?


1. It produces the minimum spanning tree

2. It produces all pair shortest path tree


Choose the correct answer from the options given below.

a)

Both 1 and 2 are true

b)

Both 1 and 2 are false

c)

Only 2 is true

d)

Only 1 is true

24.

What will be the output of the following pseudocode?


Integer a, b, c

Set b = 2, a = 2

c = a ^ b

Print c

[Note- ^ is the bitwise exclusive OR operator ]

a)

6

b)

4

c)

0

d)

2

25.

Which of the following series will be printed by the given pseudocode?


Integer i, j, k, n

Set j=1, k=1

for(each i from 1 to 5)

print k

j=j+1

k=k+j

end for

a)

1 3 6 10 15

b)

1 2 3 4 5

c)

2 4 6 8 10

d)

1 1 2 3 5