Logical operators from Java were inherited from C: >, >=, <, <=
have highest precedence, then come ==, !=
. All have precedence
lower than arithmetic operators. Expressions connected with &&
or ||
are evaluated from left to right, and evaluation stops as
early as it can. An expression is negated with !
if (condition) { statement(s) } tests whether condition is 0 (false) or non-zero (true), and then executes statements(s) if it is true. if (condition) { statement(s) } else { other statement(s) } executes statement(s) if condition is non-zero, and other statement(s) if condition is zero. This resembles Java, once you make the leap from boolean to int conditions.