cplusplus:control_structures_repetition_in_algorithms
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
cplusplus:control_structures_repetition_in_algorithms [2013/02/20 00:16] – created mithat | cplusplus:control_structures_repetition_in_algorithms [2014/02/24 22:12] – mithat | ||
---|---|---|---|
Line 2: | Line 2: | ||
~~NOTOC~~ | ~~NOTOC~~ | ||
- | ====== Control Structures: Repetition in algorithms | + | ====== Control Structures: Repetition in Algorithms |
Mithat Konar\\ | Mithat Konar\\ | ||
- | 2013-02-03 | + | 2014-02-24 |
===== Introduction ===== | ===== Introduction ===== | ||
Line 11: | Line 11: | ||
* Input validation | * Input validation | ||
* Sentinel/ | * Sentinel/ | ||
- | * Menus | ||
* Counter control | * Counter control | ||
* Iterators | * Iterators | ||
===== Input validation ===== | ===== Input validation ===== | ||
- | * Do not continue with program | + | * " |
* Pseudo code:< | * Pseudo code:< | ||
While input value is not valid | While input value is not valid | ||
Get input value from user</ | Get input value from user</ | ||
- | ===== Sentinel/flag control ===== | + | ===== Sentinel control ===== |
* **Sentinel**: | * **Sentinel**: | ||
- | * Value(s) that indicate(s) a special condition; " | + | * Value(s) that indicate(s) a special condition---a " |
+ | |||
+ | ===== Sentinel-controlled repetition ===== | ||
+ | * " | ||
+ | * Pseudo code:< | ||
+ | While input value is not SENTINEL value | ||
+ | Do something | ||
+ | Get input value</ | ||
+ | * Input validation might be considered a special case of sentinel controlled repetition. | ||
* **Flag**: | * **Flag**: | ||
* Sometimes used as a synonym for sentinel | * Sometimes used as a synonym for sentinel | ||
* Sometimes means a sentinel that is a Boolean value | * Sometimes means a sentinel that is a Boolean value | ||
- | |||
- | ===== Sentinel-controlled repetition ===== | ||
- | * **Sentinel-controlled repetition**: | ||
- | * Repeat as long as a sentinel condition is not matched | ||
- | * Pseudo code:< | ||
- | do something</ | ||
- | * Input validation might be considered a special case of sentinel controlled repetition. | ||
===== Menus ===== | ===== Menus ===== | ||
Line 45: | Line 45: | ||
Get menu choice from user</ | Get menu choice from user</ | ||
- | ===== Counter | + | ===== Counter-controlled repetition |
- | TODO | + | * " |
+ | * Uses a counter variable. | ||
+ | * Pseudo code:< | ||
+ | While counter has not yet exceeded the STOP_VALUE | ||
+ | Do something | ||
+ | Increment counter</ | ||
===== Iterators ===== | ===== Iterators ===== | ||
- | TODO | + | * Do something to every item in a collection. |
+ | * Pseudo code:< | ||
+ | Do something with or to the item</ | ||
cplusplus/control_structures_repetition_in_algorithms.txt · Last modified: 2020/02/10 21:45 by mithat