Pseudo-code · Question 1 · Easy
What will be the output of the following pseudocode?
Integer a, b
Set a = 15, b = 4
a = a + b
b = a - b
a = a - b
Print a, b
- 15 4
- 19 15
- 4 15
- 4 4
Answer and explanation
Answer: C. 4 15
Explanation: a becomes 19, then b = 19 - 4 = 15, then a = 19 - 15 = 4. The values are swapped without a temporary variable.
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? (Note: for-loop bounds…
- What will be the output of the following pseudocode? (Note: &, | and ^ are…
- What will be the output of the following pseudocode? (Note: / denotes integer…
- 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?
- 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: / denotes integer…
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