C Programming - Bitwise Operators - Discussion

Discussion Forum : Bitwise Operators - General Questions (Q.No. 3)
3.
Which bitwise operator is suitable for turning on a particular bit in a number?
&& operator
& operator
|| operator
| operator
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
24 comments Page 2 of 3.

Swapna said:   1 decade ago
|| it will call as logical OR.here OR truth table is true false=true, true true=true.so here OR operator is on a particular bit in a number.

Datta said:   1 decade ago
Logical OR ||

Ex: if(a || b) { ... }


Bitwise OR |

Ex: result = a | b;

Samanth said:   2 decades ago
Can you tellme how?

Swetha said:   1 decade ago
@Namo

You are right and its easily understandable.

Mansi said:   1 decade ago
If | is OR operator than what do we call || operator as?

Vijay Arora said:   1 decade ago
Best use of the & operator is to check whether a particular bit od an operand is ON or OFF.

Why, we are not using &. ?

Amrendra said:   1 decade ago
@Rupa:.

If input is 0, you have to use 1 i.e. 0|1=1.

Rupa said:   1 decade ago
But when 0|0=0 so how to turn on this?

Parul said:   1 decade ago
Nano is absolutely correct. My doubt is clear now.

Join2piyush said:   1 decade ago
Anji here you take input as 1 & we want output 1 i.e. on.

But when our input is 0 & we want output as 1 I. E. On.

At that time if we & with 1 or & with 0 output will be always 0.

That's why we hav 2 use | to on the bit.


Post your comments here:

Your comments will be displayed after verification.