August 2003
Intermediate to advanced
1104 pages
19h 27m
English
Figure 3.1 lays out the form of an if statement.
if(expression1) { This block gets executed if expression1 is true. } elseif(expression2) { This block gets executed if expression1 is false and expression 2 is true. } else { This block gets executed if both expression1 and expression2 are false. } |
The if statement executes a statement if the expression inside the parentheses evaluates to true; otherwise, the code is skipped. It may be a single statement followed by a semicolon. Usually it's a compound statement surrounded by curly braces. An else statement may appear immediately after the statement and have a statement of its own. It too may be either single or compound. It is executed ...