Pseudo-code · Question 4 · Easy
What will be the output of the following pseudocode? (Note: &, | and ^ are bitwise AND, OR and XOR.)
Integer p, q
Set p = 6, q = 9
Print (p & q) + (p | q)
- 0
- 15
- 30
- 6
Answer and explanation
Answer: B. 15
Explanation: 6 is 0110 and 9 is 1001 in binary. They share no 1-bits, so 6 & 9 = 0 and 6 | 9 = 1111 = 15. The sum is 15.
Previous: What will be the output of the following pseudocode? (Note: for-loop bounds… · 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?
- 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: / 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