User Tools

Site Tools


cplusplus:control_structures_repetition_in_algorithms

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
cplusplus:control_structures_repetition_in_algorithms [2013/02/20 00:16] – created mithatcplusplus: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/flag control   * Sentinel/flag control
-    * Menus 
   * Counter control   * Counter control
   * Iterators   * Iterators
  
 ===== Input validation ===== ===== Input validation =====
-    * Do not continue with program until user has entered valid data.+    * "Prevent moving to next section until user has entered valid data."
     * Pseudo code:<code>Get input value from user     * Pseudo code:<code>Get input value from user
 While input value is not valid While input value is not valid
     Get input value from user</code>     Get input value from user</code>
  
-===== Sentinel/flag control =====+===== Sentinel control =====
  
   * **Sentinel**:   * **Sentinel**:
-    * Value(s) that indicate(s) a special condition"special value"+    * Value(s) that indicate(s) a special condition---a "special value" 
 + 
 +===== Sentinel-controlled repetition ===== 
 +  * "Repeat as long as a sentinel condition is not matched." 
 +  * Pseudo code:<code>Get input value 
 +While input value is not SENTINEL value 
 +    Do something 
 +    Get input value</code> 
 +  * 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:<code>While input value is not -999 
-    do something</code> 
-  * Input validation might be considered a special case of sentinel controlled repetition. 
  
 ===== Menus ===== ===== Menus =====
Line 45: Line 45:
     Get menu choice from user</code>     Get menu choice from user</code>
  
-===== Counter control ===== +===== Counter-controlled repetition ===== 
-TODO+  * "Repeat something a known number of times." 
 +  * Uses a counter variable. 
 +  * Pseudo code:<code>Set counter's initial value 
 +While counter has not yet exceeded the STOP_VALUE 
 +    Do something 
 +    Increment counter</code> 
  
 ===== Iterators ===== ===== Iterators =====
-TODO+  * Do something to every item in a collection. 
 +  * Pseudo code:<code>For each item in collection 
 +    Do something with or to the item</code> 
  
cplusplus/control_structures_repetition_in_algorithms.txt · Last modified: 2020/02/10 21:45 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki