Introducing the if()… else… complex statement
if()… else…
is a complex statement that can have two forms – a simple form where the if()…
part is present, and a complete form where both the if()…
and else…
parts are present.
In the if()… else…
complex statement, either the true
path or the false
path will be executed. The path that is not taken will be ignored. In the simplest if()…
statement where there is no false
path, the true
path is executed only if the conditional expression is true
.
The statement has two syntactical forms, as follows:
- The simplest form (no
false
path), as illustrated in the following code snippet:if( expression ) statement1 statement3 /* next statement to be executed */
- The complete form (both the
true
path and thefalse
path), as illustrated in the following code snippet:if( expression ) ...