PDA

View Full Version : we used single & and single | logical operator in condition



sana.pari
04-24-2011, 06:39 PM
sir can we used single & and single | logical operator in condition if yes then what is difference of double && and double ||?

Support
04-24-2011, 06:39 PM
Dear Student,
In C/C++ programming, & is different from &&. As && is boolean AND operator which is used to evaluate complex conditiond where as & operator is different from the && operator and it is address operator. Topic related to address operator (&) will be discussed in coming lectures.
both | and || are different from each other. || is the correct boolean OR operator but | is wrong.

Difference between && OPERATOR and || OPERATOR

The operator && corresponds to Boolean logical operation AND. This operation results true if both its two operands are true, and false otherwise. whereas the operator || corresponds to Boolean logical operation OR. This operation results true if either one of its two operands is true, thus being false only when both operands are false themselves.


Hopefully, everything is clear to you now.