2. Conditional Expressions
Conditional and Logical Operators: operands are any basic type, result is 0 or 1Table is in decreasing order of precedence, associativity is left-to-right for all except !
Math/ Logic | C |
---|---|
NOT | ! |
< | < |
≤ | <= |
> | > |
≥ | >= |
≡ | == |
≠ | != |
AND | && |
OR | || |
Expressions: Math C same as ---- ---- ------- x+y ≥ 9.1 x+y >= 9.1 (x+y) >= 9.1 5 < a < 10 5 < a && a < 10 (5 < a) && (a < 10) |k| ≥ 3 fabs(k) >= 3 !(fabs(k) < 3) a ≡ b ≡ c a == b && b == c (a == b) && (b == c) NOT A AND B OR C !A && B || C ((!A) && B) || CPractice!