Output of C++ programs | Set 48 (Bit Manipulation)
Q.1 What Is The Output Of this program ?
a) -36 11
b) -35 -12
c) 220 11
d) 36 11
Explanation:- For any integer n, bitwise complement of n always will be -(n+1). so here -(35+1) and-(-12+1).
Q.2 What Is The Output Of this program ?
Explanation:- In This program, we simple perform a XOR operation between 12(1010) and 25(11001) so result is(10011) equal to the 21, then perform and operation.
Q.3 What Is The Output Of this program ?
Explanation:- We know that Negative numbers are represented using 2’s complement of its positive equivalent. So the 2’s complement of 8 is (11111000) and we shifted its 1 so its (01111100) is 124.
Q.4 What Is The Output Of this program ?
ans :- -64
Explanation:- In this code, we are right shifting -128 by 1. The result will be “-64”, binary shift is applied since the operand is a signed value are printed.
Q.5 What Is The Output Of this program ?
Explanation:- In this program integer a is 3 its binary (011) shifted 3 its(011000) equal to the 24 and add 3 so its equal to the 27.
This article is contributed by Gyayak jain . If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.