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
  1. 20
  2. 22
  3. 12
  4. 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

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