About 2,390,000 results
Open links in new tab
  1. If the condition is true, the statement(s) is executed else the next_statement is executed. Similar to the loop discussed in the previous worksheet, if there is more than one line of code, you need to use the …

  2. Complex if/else statements Several statements can be grouped together into a block statement

  3. Use to execute only certain portions of code Else If is optional – Can have any number of else if statements

  4. An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement. An if can have zero or one else's and it must …

  5. The if/else construct is frequently referred to as a two-sided decision - actions are taken regardless of whether the condition is true. When the condition is true, the “true” actions are executed.

  6. We will go with Option #2: we will require that the two branches of if-then-else evaluate to the same type. In practice all languages make this design choice so that type-checking is eficient.

  7. The code following the “if” is executed when the condition is true, while the code following the “else” is executed when the condition is false. This is called a “two way branch”, as shown in the example below.