Question 31
MediumWhat will be the output of the following pseudocode?
Integer n = 40
Print n & (n - 1)
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Pseudocode and Output Prediction
What will be the output of the following pseudocode?
Integer n = 40
Print n & (n - 1)
8
39
32
40
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer n = 40
Print n & (-n)
40
8
1
32
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 5
x = x | (1 << 1)
Print x
7
5
10
6
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 15
x = x & ~(1 << 2) // ~ flips every bit
Print x
13
4
15
11
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer x = 10
Print (x >> 1) & 1
2
0
5
1
Sign up free to see the answer and a step-by-step explanation.
What will be printed by the following pseudocode?
Integer a = 12, b = 10
Print a & b, a | b, a ^ b
8 14 2
10 12 6
14 8 6
8 14 6
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer x = 5
x = x << 3
x = x >> 1
Print x
40
20
80
10
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer n = 45, c = 0
while (n > 0)
if (n & 1)
c = c + 1
end if
n = n >> 1
end while
Print c
5
4
3
6
Sign up free to see the answer and a step-by-step explanation.
What is the output of this pseudocode?
Integer a = 7, b = 9
a = a ^ b
b = a ^ b
a = a ^ b
Print a, b
7 9
0 0
9 7
14 7
Sign up free to see the answer and a step-by-step explanation.
What will be the output of the following pseudocode?
Integer n = 64
if (n > 0 and (n & (n - 1)) == 0)
Print "power of two"
else
Print "not"
end if
64
power of two
not
error
Sign up free to see the answer and a step-by-step explanation.