previous | start | next

## Boolean Operations

- The `&&` and `||` operators are computed using lazy evaluation.
- The expressions are evaluated from left to right, and evaluation stops as soon as the truth value is determined.

  >     if (cin.fail() || area < 0) cout << "Input error.\n";

  >     if (r >= 0 && -b / 2 + sqrt(r) >= 0) ...

- The `!` (not) operator takes a single condition and evaluates to true if that condition is false and to false if that condition is true.

  >     if (!cin.fail()) quarters = quarters + n;

- Summary:

  A | B | A && B
  true | true | true
  true | false | false
  false | Any | false
  A | B | A ||B
  true | Any | true
  true | false | true
  false | false | false
  A | !A
  true | false
  false | true

previous | start | next