ProgrammingModerateTCS NQT · Accenture 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.)
Integer a = 12, b = 10 Print a & b, a | b, a ^ b
- A. 8 14 6
- B. 8 14 2
- C. 2 14 6
- D. 10 12 6
Correct answer: A. 8 14 6
12 = 1100 and 10 = 1010. AND = 1000 = 8, OR = 1110 = 14, XOR = 0110 = 6.
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? Integer c = 0 for (each i from 1 to 4) for (each j from i to 4) c = c + 1 end for end…
- What will be the output of the following pseudocode? (All variables are integers, so / is integer division.) Function fun(Integer n) if (n…
- What will be the output of the following pseudocode? Integer a = 48, b = 18, t while (b != 0) t = b b = a mod b a = t end while Print a
- What will be the output of the following pseudocode? Integer p = 2, q = 3 for (each i from 1 to 3) p = p q q = q - 1 end for Print p + q
- What will be the output of the following pseudocode? (Arrays are indexed from 0.) Integer arr[6] = {1, 2, 3, 4, 5, 6} for (each i from 0…