Pseudo-code · Question 10 · Medium
What will be the output of the following pseudocode? (Note: << and >> are bitwise left and right shift.)
Integer x
Set x = 5
x = (x << 2) + (x >> 1)
Print x
- 20
- 22
- 12
- 25
Answer and explanation
Answer: B. 22
Explanation: 5 << 2 multiplies by 4, giving 20. 5 >> 1 divides by 2 and drops the fraction, giving 2. 20 + 2 = 22.
Previous: What will be the output of the following pseudocode? · Next: What will be the output of the following pseudocode? (Note: / denotes integer…
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? (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: / denotes integer…
- 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…
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