|
|
|
|
|
|
true || true|| false == true true||false|| false == true true || false || true ==true. false||false||false== false |
statement && statement && statement
false&& true&& true == false; false && false && true== false; true&& true&& true == true; false&&false&&false == false; |
if (a && b || c)
if (a && (b || c))
if (b || c && a)
if (b || (c && a))
fg109 wrote: |
---|
the right-most is evaluated first: |
|
|
a = 1, b = 1, c = 1 (a && b || c) = true ((a && b) || c) = true (a && (b || c)) = true (a || b && c) = true ((a || b) && c) = true (a || (b && c)) = true a = 1, b = 1, c = 0 (a && b || c) = true ((a && b) || c) = true (a && (b || c)) = true (a || b && c) = true ((a || b) && c) = false (a || (b && c)) = true a = 1, b = 0, c = 1 (a && b || c) = true ((a && b) || c) = true (a && (b || c)) = true (a || b && c) = true ((a || b) && c) = true (a || (b && c)) = true a = 1, b = 0, c = 0 (a && b || c) = false ((a && b) || c) = false (a && (b || c)) = false (a || b && c) = true ((a || b) && c) = false (a || (b && c)) = true a = 0, b = 1, c = 1 (a && b || c) = true ((a && b) || c) = true (a && (b || c)) = false (a || b && c) = true ((a || b) && c) = true (a || (b && c)) = true a = 0, b = 1, c = 0 (a && b || c) = false ((a && b) || c) = false (a && (b || c)) = false (a || b && c) = false ((a || b) && c) = false (a || (b && c)) = false a = 0, b = 0, c = 1 (a && b || c) = true ((a && b) || c) = true (a && (b || c)) = false (a || b && c) = false ((a || b) && c) = false (a || (b && c)) = false a = 0, b = 0, c = 0 (a && b || c) = false ((a && b) || c) = false (a && (b || c)) = false (a || b && c) = false ((a || b) && c) = false (a || (b && c)) = false |
a = 0, b = 1, c = 1 (a && b || c) = true ((a && b) || c) = true (a && (b || c)) = false [...] a = 0, b = 0, c = 1 (a && b || c) = true ((a && b) || c) = true (a && (b || c)) = false |
a = 1, b = 1, c = 0 [...] (a || b && c) = true ((a || b) && c) = false (a || (b && c)) = true [...] a = 1, b = 0, c = 0 [...] (a || b && c) = true ((a || b) && c) = false (a || (b && c)) = true |
Peter87 wrote: |
---|
&& has higher precedence than || so (a && b || c) is the same as ((a && b) || c), and (a || b && c) is the same as (a || (b && c)). |