| << 5.3.0- Types of Control Statements | Chapter5 | 5.3.2- Looping Controls >> |
Branching Structures
Branching controls perform some type of test. Based on the test results, a set of code will be executed and other sets of code will be skipped. From our Motorpool example, this is like testing if the gasoline tank is full. If it is not full then we perform the steps to fill it. If the tank is full then we skip the filling steps and move on to the next lines of code.
There are two types of branching structures.
- If...Then...Else – generally used to select one of several sets of lines to execute based on a condition to be met. A simple example would be in a page announcing a meeting: we could have one of two different meeting room numbers shown depending on whether the addressee was in the Sales or R&D department. If Then is also the tool of choice for complicated comparisons, such as expressions using the terms and, or, not.
- Select Case – generally used to select one set of lines to execute from many possibilities. For example, in a page announcing a meeting we could have the room number of one of five different meeting rooms shown, depending on whether the addressee was in the Sales, R&D, Distribution, Personnel, or Accounting department.
| << 5.3.0- Types of Control Statements | Chapter5 | 5.3.2- Looping Controls >> |

RSS

