cplusplus:control_structures_repetition_in_algorithms
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
cplusplus:control_structures_repetition_in_algorithms [2017/02/06 17:32] – mithat | cplusplus:control_structures_repetition_in_algorithms [2020/02/10 21:45] (current) – [Menus] mithat | ||
---|---|---|---|
Line 5: | Line 5: | ||
Mithat Konar\\ | Mithat Konar\\ | ||
- | 2017-02-06 | + | 2019-02-11 |
===== Introduction ===== | ===== Introduction ===== | ||
Line 18: | Line 18: | ||
* " | * " | ||
* Uses a counter variable. | * Uses a counter variable. | ||
- | * Pseudo code:< | + | * Pseudocode:< |
While counter has not yet exceeded the STOP_VALUE | While counter has not yet exceeded the STOP_VALUE | ||
Do something | Do something | ||
Line 26: | Line 26: | ||
* **Sentinel**: | * **Sentinel**: | ||
- | * Value(s) that indicate(s) a special condition---a " | + | * Value(s) that indicate(s) a special condition --- a " |
===== Sentinel-controlled repetition ===== | ===== Sentinel-controlled repetition ===== | ||
* " | * " | ||
- | * Pseudo code:< | + | * Pseudocode:< |
- | While input value is not SENTINEL value | + | While value is not SENTINEL value |
Do something | Do something | ||
- | Get input value</ | + | Get value</ |
* Input validation might be considered a special case of sentinel controlled repetition. | * Input validation might be considered a special case of sentinel controlled repetition. | ||
* **Flag**: | * **Flag**: | ||
Line 41: | Line 41: | ||
===== Input validation ===== | ===== Input validation ===== | ||
* " | * " | ||
- | * Pseudo code:< | + | * Pseudocode:< |
While input value is not valid | While input value is not valid | ||
Get input value from user</ | Get input value from user</ | ||
Line 47: | Line 47: | ||
===== Menus ===== | ===== Menus ===== | ||
* Repeating menus can be implemented with sentinel control. | * Repeating menus can be implemented with sentinel control. | ||
- | * Pseudo code:< | + | * Pseudocode:< |
Get menu choice from user | Get menu choice from user | ||
While input value is not QUIT value | While input value is not QUIT value | ||
- | | + | Process the menu choice |
Show menu | Show menu | ||
Get menu choice from user</ | Get menu choice from user</ | ||
Line 56: | Line 56: | ||
===== Iterators ===== | ===== Iterators ===== | ||
* Do something to every item in a collection. | * Do something to every item in a collection. | ||
- | * Pseudo code:< | + | * Pseudocode:< |
Do something with or to the item</ | Do something with or to the item</ | ||
cplusplus/control_structures_repetition_in_algorithms.1486402354.txt.gz · Last modified: 2017/02/06 17:32 by mithat