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
cplusplus:control_structures_repetition_in_algorithms [2014/02/24 22:09] mithatcplusplus:control_structures_repetition_in_algorithms [2020/02/10 21:45] (current) – [Menus] mithat
Line 2: Line 2:
 ~~NOTOC~~ ~~NOTOC~~
  
-====== Control Structures: Repetition in algorithms ======+====== Control Structures: Repetition in Algorithms ======
  
 Mithat Konar\\  Mithat Konar\\ 
-2014-02-24+2019-02-11
  
 ===== Introduction ===== ===== Introduction =====
  
-  * Input validation 
-  * Sentinel/flag control 
   * Counter control   * Counter control
 +  * Sentinel/flag control
 +  * Input validation
 +  * Menus
   * Iterators   * Iterators
  
-===== Input validation ===== +===== Counter-controlled repetition ===== 
-    * "Prevent moving to next section 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 +  * Pseudocode:<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"
  
 ===== Sentinel-controlled repetition ===== ===== Sentinel-controlled repetition =====
   * "Repeat as long as a sentinel condition is not matched."   * "Repeat as long as a sentinel condition is not matched."
-  * Pseudo code:<code>Get input value +  * Pseudocode:<code>Get value 
-While input value is not SENTINEL value+While value is not SENTINEL value
     Do something     Do something
-    Get input value</code>+    Get 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**:   * **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
 +
 +===== Input validation =====
 +    * "Prevent moving to next section until user has entered valid data."
 +    * Pseudocode:<code>Get input value from user
 +While input value is not valid
 +    Get input value from user</code>
  
 ===== Menus ===== ===== Menus =====
   * Repeating menus can be implemented with sentinel control.   * Repeating menus can be implemented with sentinel control.
-  * Pseudo code:<code>Show menu+  * Pseudocode:<code>Show menu
 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>+    Process the menu choice
     Show menu     Show menu
     Get menu choice from user</code>     Get menu choice from user</code>
- 
-===== Counter-controlled repetition ===== 
-  * "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 =====
   * Do something to every item in a collection.   * Do something to every item in a collection.
-  * Pseudo code:<code>For each item in collection+  * Pseudocode:<code>For each item in collection
     Do something with or to the item</code>     Do something with or to the item</code>
  
  
cplusplus/control_structures_repetition_in_algorithms.1393279755.txt.gz · Last modified: 2014/02/24 22:09 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki