
The basic attribute of a selection control structure is to be able to select between two or more alternate paths. This is described as either two-way selection or multiway selection. A question using Boolean concepts usually controls which path is selected. All of the paths from a selection control structure join back up at the end of the control structure, before moving on to the next lines of code in a program.
We have mentioned that the if then else control structure belongs to the selection category and is a two-way selection.
Example 10.1: if then else control structure
if (age > l7) { cout « "You can vote."; } else { cout « "You can't vote."; }
- 4554 reads