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.

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

Swetha said:   1 decade ago
@Namo

You are right and its easily understandable.

Viny said:   1 decade ago
Namo is correct.

Datta said:   1 decade ago
Logical OR ||

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


Bitwise OR |

Ex: result = a | b;

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.

Suni said:   1 decade ago
What is difference between logical and bitwise OR?

Bujji said:   1 decade ago
This answer is wright because "|"this operator is called OR. It is a particular turning operator.

Khushboo said:   1 decade ago
What is difference between logical and bitwise OR?

Yugandhar said:   1 decade ago
@Khushboo.

Logical OR operator is operated on two values that are True(T or 1) and False(F or 0)
i.e --(1)-- || --(2)--

(1),(2) are any expression that gives 0 or 1

Ex:

1||1=1
1||0=1
0||1=1
0||0=0

But if we see bit-wise OR operator ,it operated on any two integer values x,y.

Ex: x|y

In this every integer is represented by binary numbers, then OR operator is operated on each bit.

Ex:

10|6 gives 14 ; 10||6 gives 1
10 --> (1010) ; true || true =true
6 --> (0110) ;
---------------- ;
14 --> 1110 ;

Vijay makhijani said:   1 decade ago
As we know to turn on any state we need the output as 1.

We can easily get it if we use the OR (|) operator. As only a single 1 and all others as 0's would also result in the on state if we use the (|) operator.


Post your comments here:

Your comments will be displayed after verification.