if [C++ Reference]
Keywords: keywords,if
Date: 2008-10-14T15:42:04-0700

[[if]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## if

Syntax:

        if( conditionA ) {
          statement-listA;
        }
        else if( conditionB ) {
          statement-listB;
        }
        ...
        else {
          statement-listN;
        }

The if construct is a branching mechanism that allows different code to execute under different conditions. The conditions are evaluated in order, and the statement-list of the first condition to evaluate to true is executed. If no conditions evaluate to true and an else statement is present, then the statement list within the else block will be executed. All of the else blocks are optional.

Related Topics: else, for, switch, while

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •