ProgrammingHardCapgemini · Infosys pattern
What will be the output of the following pseudocode? (& is bitwise AND, | is bitwise OR, ^ is bitwise XOR, << and >> are left and right shifts.)
What will be the output of the following pseudocode? (& is bitwise AND, | is bitwise OR, ^ is bitwise XOR, << and >> are left and right shifts.)
Print ((13 & 7) << 2) | (9 >> 2)
- A. 23
- B. 22
- C. 54
- D. 20
Correct answer: B. 22
13 & 7 = 1101 & 0111 = 0101 = 5. 5 << 2 = 20 = 10100. 9 >> 2 = 2 = 00010. 20 | 2 = 10110 = 22.
Practise more Pseudocode and Code Tracing questionsPseudocode and Code Tracing: notes and key points
More Pseudocode and Code Tracing questions
- What will be the output of the following pseudocode? (& is bitwise AND, | is bitwise OR, ^ is bitwise XOR, << and >> are left and right…
- What will be the output of the following pseudocode? (Arrays are indexed from 0.) Integer arr[4] = {2, 3, 1, 0} for (each i from 0 to 3)…
- What will be the output of the following pseudocode? Function f(Integer n) if (n > 100) return n - 10 end if return f(f(n + 11)) End…
- What will be the output of the following pseudocode? Function A(Integer m, Integer n) if (m == 0) return n + 1 end if if (n == 0) return…
- What will be the output of the following pseudocode? Integer s = 0 for (each i from 1 to 4) for (each j from 1 to 4) if ((i j) mod 3 == 0)…
- What will be the output? (A do-while loop runs its body once before checking the condition; / is integer division.) Integer x = 0, c = 0…