C Programming - Bitwise Operators - Discussion
Discussion Forum : Bitwise Operators - General Questions (Q.No. 4)
4.
Which bitwise operator is suitable for checking whether a particular bit is on or off?
Discussion:
29 comments Page 2 of 3.
Joyeeta said:
1 decade ago
While doing bitwise operation, when we do 1&0, we get 0, means the bit is off. When we do 1&1, this proves that the bit is on.
Pritam said:
10 years ago
I don't understand, why always & operator use. Truth table of | or operator also provides logical relation then why always &?
Ajendra Singh said:
1 decade ago
Relation operator is used to make an expression to compound one whereas bitwise and is used to operate on bits for faster access.
Bhavin said:
1 decade ago
In case & and | both options will be given in question. What will answer for this question?please give my answer.
Ghanshyam Sharma said:
1 decade ago
I think that the right answer is D.
For eg:
If I write if(a) then it is 1.
If I write if(!a) then it is 0.
For eg:
If I write if(a) then it is 1.
If I write if(!a) then it is 0.
Dimple said:
1 decade ago
Why we can't use the OR (|) operator instead of AND (&) for checking whether the bit is on or off?
Payal said:
1 decade ago
&& is a relational operator it compare two values.
Whereas & is logical operator.
Whereas & is logical operator.
Rahul_B said:
9 years ago
@Pritam & @Guru Sai.
There is no option of OR(|) in the given question.
How it be? Explain.
There is no option of OR(|) in the given question.
How it be? Explain.
Shritama said:
1 decade ago
x & 1 = x.
x | 0 = x.
Here no | option.
Only & option.
So answer B.
x | 0 = x.
Here no | option.
Only & option.
So answer B.
Siraj said:
1 decade ago
Hey anybody can explain me how & operatoer is used to chek on or off ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers