Worksheetspseudocode
Total questions: 25
Worksheet time: 13mins
If a grade of 98 was inputted, what would be the output?
Passed
Failed
Else
If the grade of 60 was input, what would be the output?
Passed
Failed
Else
If the grade of 12 was input, what would be the output?
Passed
Failed
Else
What would the program output with the following inputs?
Payrate - 12
Hours Worked - 10
12
Final pay
OUTPUT
120
Fill in the first blank
Larger
IF
THEN
WHILE
What happens when the grade counter reaches 10.
Remember: <= means less than or equal to
We add 1 to the grade counter
The while loop keeps going
We output out the average
We end the while loop
What happens when the grade counter reaches 11.
Remember: <= means less than or equal to
We add 1 to the grade counter
The while loop keeps going
We output out the average
We end the while loop
Which type of iteration should be used when you know how many times you want to loop?
Count Controlled
Condition Controlled
Which type of iteration should you use if you don't know how many times you need to loop?
Condition Controlled
Count Controlled
What is missing?
____ i = 1 To 10
OUTPUT: "String"
ENDFOR
FOR
FOUR
WHILE
Fill in the missing blank:
_______ variable <> "Hi"
OUTPUT: "Hi to you!"
ENDWHILE
WHILST
WHILE
FOR
IF
Pick the correct answer to match the following:
A loop that will check the condition before the code inside is executed.
FOR
WHILE
REPEAT...UNTIL
Pick the correct answer to match the following:
A loop that will check the condition after the code inside is executed.
WHILE
REPEAT...UNTIL
FOR
Which of the following will run 10 times? (Choose all that apply.)
FOR i = 1 TO 10
OUTPUT: "Number " + i
ENDFOR
FOR i = 0 To 10
OUTPUT: "Number: " + i
ENDFOR
input = 10
count = 1
WHILE count <= input
OUTPUT: count
count = count + 1
ENDWHILE
Complete the blank:
" (a) is the process of repeating an action multiple times."
Which of these is the correct syntax? (Choose all that apply.)
FOR i = 1 TO 10
WHILE i != 10
FOR i = 1 <- 10
WHILE i <> 10
How many times will the following loop run?
myString = "A word"
FOR i = 1 TO LENGTH(myString)
'Do something
ENDFOR
6
5
10
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
5 5 5
Infinite loop
6 6 5
6 5 4
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
5
3
4
0
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
8
7
9
2
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
0
2
7
15
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
5
26
13
2
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.
Both 1 and 2 are true
Both 1 and 2 are false
Only 2 is true
Only 1 is true
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 ]
6
4
0
2
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
1 3 6 10 15
1 2 3 4 5
2 4 6 8 10
1 1 2 3 5
