Chains of Conditional Statements

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

*if-else statements can be chained in following form:

if ( Expression1 ) {
    Statement1a
    Statement1b
    ...
} else if ( Expression2 ) {
    Statement2a
    Statement2b
    ...
} else if ( Expression3 ) {
    Statement3a
    Statement3b
    ...
} else {
    Statement4a
    Statement4b
    ...
}

 

*The execution evaluates all conditional expressions beginning from Expression1 until the first expression is found that evaluates to true. Then the corresponding statement sequence is executed, or, if none of the expressions evaluated to true, the statement sequence of the final else part.
 

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002