Namespaces
Variants
Views
Actions

Logical operators

From cppreference.com
< c‎ | language
Revision as of 06:35, 26 October 2012 by OrangeBuzzard (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Logical operators apply standard boolean algebra operations to their operands.


Operator Operator name Example Result
! logical NOT !a the logical negation of a
&& logical AND a && b the logical AND of a and b
|| logical OR a || b the logical OR of a and b

Short-circuit evaluation

&& and || perform short-circuit evaluation (do not evaluate the second operand if the result is known after evaluating the first).

See Also

Operator precedence

Common operators
assignment increment
decrement
arithmetic logical comparison member
access
other

a = b
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b

++a
--a
a++
a--

+a
-a
a + b
a - b
a * b
a / b
a % b
~a
a & b
a | b
a ^ b
a << b
a >> b

!a
a && b
a || b

a == b
a != b
a < b
a > b
a <= b
a >= b

a[b]
*a
&a
a->b
a.b

a(...)
a, b
(type) a
? :
sizeof
_Alignof
(since C11)