Pseudo-code · Question 11 · Medium
What will be the output of the following pseudocode? (Note: / denotes integer division.)
Integer n, r, s
Set n = 4825, s = 0
while (n > 0)
r = n mod 10
if (r mod 2 == 0)
s = s + r
end if
n = n / 10
end while
Print s
- 19
- 5
- 12
- 14
Answer and explanation
Answer: D. 14
Explanation: The digits of 4825 are taken from the right: 5, 2, 8, 4. Only even digits are added: 2 + 8 + 4 = 14.
Previous: What will be the output of the following pseudocode? (Note: << and >> are… · Next: What will be the output of the following pseudocode?
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?
- What will be the output of the following pseudocode? (Note: << and >> are…
- What will be the output of the following pseudocode?
- What will be the output of the following pseudocode? (Note: &, | and ^ are…
- What will be the output of the following pseudocode? (Note: for-loop bounds…
- What will be the output of the following pseudocode? (Note: array indices…
- What will be the output of the following pseudocode? (Note: / denotes integer…
- What will be the output of the following pseudocode? (Note: for-loop bounds…
- What will be the output of the following pseudocode?
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