What will be the output of the program?
- 2 -6 5
- 2 -6 1
- 2 2 1
- Compiler error
- None of these
Correct answer 3)2 2 1
Explanation:
The statement int p:3; allows selecting only the last bits of the number
So,
The binary value of 2: 00000010 (Select three two-bit) we get 010 which is 2 in decimal.
Similarly,
The binary value of 6: 00000110
The binary value of -6: 11111001+1=11111010 (Select last three-bit) we get 010 which is 2 in decimal
The binary value of 5: 00000101 (Select last two-bit) we get 01 which is 1 in decimal
0 comments:
Post a Comment