|Home | Tutorial | Classes | Functions | QSA Workbench | Language | Qt API | QSA Articles | Qt Script for Applications | ![]() |
[Prev: for] [Home] [Next: finally]
if ( expression1 ) { // statements1 else { // elsestatements } if ( expression1 ) { // statements1 else if ( expression2 ) { // statements2 } // else if ... else { // elsestatementsN }
An if statement provides a two-way branch. A multi-way branch is achieved using else ifs. (See also switch.)
If the first expression, expression1, is true, then the statements governed by that expression (statements1) will be executed, after which control will pass to the statement following the if block.
If expression1 is false, control passes to the else statement. If the else has no following if, the else statements (elsestatements) are executed, after which control will pass to the statement following the if block. If the else has a following if, then step 1 or step 2 (this step) is repeated for that if statement depending on whether its expression is true or false.
[Prev: for] [Home] [Next: finally]
Copyright © 2001-2006 Trolltech | Trademarks | QSA version 1.1.5
|