# C Programming - Bitwise Operators - Discussion

### Discussion :: Bitwise Operators - General Questions (Q.No.4)

4.

Which bitwise operator is suitable for checking whether a particular bit is on or off?

 [A]. && operator [B]. & operator [C]. || operator [D]. ! operator

Explanation:

No answer description available for this question.

 Kishore said: (Aug 10, 2010) As we know that truth table of AND is if 2 number is true then only output becomes true. For that reason & is used to find bits on or off.

 Harshit Bhatia said: (Oct 28, 2010) Yaa, & operator is perfect for find out on or off.

 Madhureddy said: (Feb 2, 2011) Hai frndz. How & operator is used to check whether a bit is on or off is as follows let us conceive that there is a binary num 10101000 if you want to check third bit is on or off then perform and operation to 00001000 then if 3rd bit is 1 its on else its turned off. Here if wana check nth bit make n-1 bit as 1 remaining as 0. Then perform and operation then you will know the answer.

 Siraj said: (Feb 4, 2011) Hey anybody can explain me how & operatoer is used to chek on or off ?

 Amit(Saktimaan) said: (Mar 3, 2011) I don't understand this.

 Seenu said: (Mar 12, 2011) Hi! Guys this is a simple one. Let consider 8-bit binary number, Binary(8 bit) = 0000 1100 suppose we want check 3rd bit is on or off(on=1 & off=0), just like this, 0000 1100 (Decimal=12) & 0000 0100 (Decimal=4,we are checking 3rd bit so it is 1) ---------- 0000 0100 (Decimal=4) ---------- If we got some value then checking bit is on,otherwise off. In C language, if(12&4) print("The third bit is on"); else print("The third bit is off");

 Riya said: (Apr 29, 2011) What is the difference between && and & ?

 Payal said: (May 23, 2011) && is a relational operator it compare two values. Whereas & is logical operator.

 Ajendra Singh said: (Aug 22, 2011) Relation operator is used to make an expression to compound one whereas bitwise and is used to operate on bits for faster access.

 Ullas Kulkarni said: (Sep 14, 2011) In detail,, The key difference between & and && is ,its return value EX; 1&2 returns zero whereas 1&&2 returns one .. check out 1=0001 & 0010= 0000 on & opertion and 1(true) and 2(true) so 1&& 2=1(true)

 Joyeeta said: (Mar 17, 2012) 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.

 Love Shukla said: (May 20, 2012) && is a Logical operator which combine two or more relation Ex: let a=5,b=2 (a==5)&& (b==2) true && true = true i.e, 1 && 1 = 1 While & is a bitwise operator which has ability to support the manipulation of data at bit level Ex:let a=9,b=15 Then, a & b 9 & 15 1001 & 1111 = 1001 (use AND operation on each bit) i.e, ans:- 9

 Saikat Sinha Ray said: (Jul 31, 2012) & is a bit wise operator that performs the AND operation of binary representation of given numbers. Ex : 2 && 0 = 0 (In binary 0000 0010 & 0000 0000 = 00000 0000) && is a logical operator that matches between two condition Ex : if(condition1 is true && condition2 is true) ................ else ................

 Shritama said: (Oct 1, 2013) x & 1 = x. x | 0 = x. Here no | option. Only & option. So answer B.

 Anusha said: (Dec 31, 2013) Yeah, & is the correct answer to turnoff the bit in a number. The basic operations of & is : 0 & 0 = 0 0 & 1 = 0 1 & 0 = 0 1 & 1 = 1.

 Bhavin said: (Feb 6, 2014) In case & and | both options will be given in question. What will answer for this question?please give my answer.

 Bit_Ter said: (Jun 15, 2014) @Bhavin the answer is & because, 0 | 1 =1 1 | 1 =1. But, 0 & 1 =0 1 & 1 =1. You can see that when you '&' a particular bit (0 or 1) with 1 then the output is the input.

 Dimple said: (Jul 16, 2014) Why we can't use the OR (|) operator instead of AND (&) for checking whether the bit is on or off?

 Kiran said: (Sep 5, 2014) What is unary operator?

 Ghanshyam Sharma said: (Dec 31, 2014) 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.

 Gajanan said: (Feb 13, 2015) @Dimple, You are correct. Why we can used (|) instead of (&)?

 Navya.Ch said: (Jul 15, 2015) Then why can't we use?

 Ramya said: (Nov 17, 2015) Can anyone explain bitwise operators by writing a program?

 Pritam said: (Jan 12, 2016) I don't understand, why always & operator use. Truth table of | or operator also provides logical relation then why always &?

 Guru Sai Jaya Prakash said: (May 24, 2016) 0 | 0 = 0. 1 | 0 = 1. So, why can't we use like this?

 Rahul_B said: (Jun 2, 2016) @Pritam & @Guru Sai. There is no option of OR(|) in the given question. How it be? Explain.

 Vykuntapu Gopi said: (Jul 18, 2016) The output of logical operators gives 0/1. The output of bitwise operators gives decimal of given numbers. Example: (a=5)&&(b=2) the a&b are both are non-zero numbers it gives result as 1 if (a=5)&&(b=0) So result is 0. Because one of operands b is zero. But in bitwise operators, the operation goes on the binary number of given operands. if (a=2)&(b=1) convert the 2,1 binary numbers in 4 bits that 8421; 2's binary number 0010 1's binary number is 0001 0&0=0 0&0=0 1&0=0 0&1=0 Output is 0

 Anand said: (Dec 7, 2016) What is the use of || operator? Please explain me friends.