Pseudo-code · Question 29 · Hard
What will be the output of the following pseudocode? (Note: for-loop bounds are inclusive.)
Integer a, b, c, i
Set a = 1, b = 1
for (i = 1 to 6)
c = (a + b) mod 10
a = b
b = c
end for
Print a * b
- 104
- 3
- 24
- 273
Answer and explanation
Answer: B. 3
Explanation: These are Fibonacci numbers with only the last digit kept. After the 6 iterations (a, b) goes (1, 2), (2, 3), (3, 5), (5, 8), (8, 3), (3, 1), so a * b = 3 × 1 = 3.
Previous: What will be the output of the following pseudocode? · Next: What will be the output of the following pseudocode? (Note: for-loop bounds…
Practise pseudo-code
Try a fresh set of pseudo-code questions with an explanation after every answer, free and without signing up: Pseudo-code practice. Or sit a full placement mock test.
More pseudo-code questions
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: array indices…
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: for-loop bounds…
More technical & programming practice
C Programming · Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge