October 1997
Intermediate to advanced
800 pages
20h 48m
English
C++ has constructs that dictate which statements execute, based on the values of expressions. This section introduces C++ constructs and describes how they affect the logic and control flow of programs.
The if construct has three formats. The first format is
if (expression) { statements; // if-block }
The expression requires parentheses. If expression evaluates to true, statements execute and control continues with the next statement following the if-block. If expression evaluates to false, control skips to the statement following the if-block. Braces are optional if there is only one statement in the if-block.
The second format is
if (expression) { statements1; } else { statements2; }
If expression ...