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

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
cplusplus:control_structures_repetition_in_algorithms [2013/03/01 00:53] mithatcplusplus:control_structures_repetition_in_algorithms [2017/02/06 17:32] mithat
Line 2: Line 2:
 ~~NOTOC~~ ~~NOTOC~~
  
-====== Control Structures: Repetition in algorithms ======+====== Control Structures: Repetition in Algorithms ======
  
 Mithat Konar\\  Mithat Konar\\ 
-2013-02-03+2017-02-06
  
 ===== Introduction ===== ===== Introduction =====
  
 +  * Counter control
 +  * Sentinel/flag control
   * Input validation   * Input validation
-  * Sentinel/flag control +  * Menus
-    * Menus +
-  * Counter control+
   * Iterators   * Iterators
  
-===== Input validation ===== +===== Counter-controlled repetition ===== 
-    * "Do not continue with program until user has entered valid data." +  * "Repeat something a known number of times." 
-    * Pseudo code:<code>Get input value from user +  * Uses a counter variable. 
-While input value is not valid +  * Pseudo code:<code>Set counter's initial value 
-    Get input value from user</code>+While counter has not yet exceeded the STOP_VALUE 
 +    Do something 
 +    Increment counter</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"
-  * **Flag**: +
-    * Sometimes used as a synonym for sentinel +
-    * Sometimes means a sentinel that is a Boolean value+
  
 ===== Sentinel-controlled repetition ===== ===== Sentinel-controlled repetition =====
Line 36: Line 35:
     Get input value</code>     Get input value</code>
   * 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**:
 +    * Sometimes used as a synonym for sentinel
 +    * Sometimes means a sentinel that is a Boolean value
 +
 +===== Input validation =====
 +    * "Prevent moving to next section until user has entered valid data."
 +    * Pseudo code:<code>Get input value from user
 +While input value is not valid
 +    Get input value from user</code>
  
 ===== Menus ===== ===== Menus =====
Line 46: Line 54:
     Get menu choice from user</code>     Get menu choice from user</code>
  
-===== Counter-controlled repetition ===== +===== Iterators ===== 
-  * "Repeat something a known number of times.+  * Do something to every item in collection
-  * Uses a counter variable +  * Pseudo code:<code>For each item in collection 
-  * Pseudo code:<code>Set counter's initial value +    Do something with or to the item</code>
-While counter has not yet exceeded the STOP_VALUE +
-    Do something +
-    Increment counter</code>+
  
- 
-===== Iterators ===== 
-* Later 
  
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