C Programming - Bitwise Operators - Discussion


Bitwise & can be used to check if a bit in number is set or not.

[A]. True
[B]. False

Answer: Option A


No answer description available for this question.

Aaradhana said: (May 25, 2011)  
Can anyone explain how?

Sundar said: (May 25, 2011)  
Assume that we have to check whether the 4th bit (from-right-side) of the given number is set or not.

Given Input: 171( Its 16-bit binary = 00000000 10101011)
Checker Data: 8 (Only 4th bit is on = 00000000 00001000)


void main()
int input = 171;
int check = 8; // 4th bit checker.

if(input & check)
printf("4th bit is set.");
printf("4th bit is NOT set.");

//output: 4th bit is set.

Hope this will help you. Have a nice day.

Jansi said: (Oct 30, 2018)  
Can anyone explain this answer? Please.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.