User Tools

Site Tools


cplusplus:control_structures_selection

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
Last revisionBoth sides next revision
cplusplus:control_structures_selection [2016/02/02 22:28] – [Control structures in C++] mithatcplusplus:control_structures_selection [2017/01/30 20:35] mithat
Line 4: Line 4:
 ====== Control Structures: Selection ====== ====== Control Structures: Selection ======
  
-Mithat Konar\\  +Mithat Konar\\
-2013-02-03+
  
 ===== Introduction ===== ===== Introduction =====
Line 27: Line 26:
 ===== Single-entry/single-exit structures ===== ===== Single-entry/single-exit structures =====
  
-  * **Single-entry/single-exit structures**: +  * Control structures that are entered from one point and exited from one point. 
-    * Control structures that are entered from one point and exited from one point. +  * Connect the exit point of one control structure to entry point of the next: **control-structure stacking**. 
-    * Connect the exit point of one control structure to entry point of the next: **control-structure stacking**. +  * Makes programs easy to build.
-    * Makes programs easy to build.+
  
 ===== Selection structures ===== ===== Selection structures =====
-  * There are four selection structures available in C++:+  * Four selection structures available in C++:
     * //if//     * //if//
     * //if/else//     * //if/else//
     * //nested if/else//     * //nested if/else//
     * //switch//     * //switch//
 +  * Also has a ternary //conditional operator// that performs selection.
  
 ===== if selection structure ===== ===== if selection structure =====
Line 251: Line 250:
   * [[selection_examples#comparing_characters|Comparing characters example]]   * [[selection_examples#comparing_characters|Comparing characters example]]
   * See Gaddis 4.12 (programs Pr4-20.cpp and Pr4-21.cpp).   * See Gaddis 4.12 (programs Pr4-20.cpp and Pr4-21.cpp).
 +
 +===== switch structure =====
 +  * [[selection_examples#switch|simple switch example]]
 +  * See Gaddis 4.14 (programs Pr4-23.cpp to Pr4-27.cpp).
  
 ===== The conditional operator ===== ===== The conditional operator =====
Line 260: Line 263:
     * Examples:<code c++>y = x<0 ? -1.0*x : x;     * Examples:<code c++>y = x<0 ? -1.0*x : x;
 w = x<0 ? y=10 : z=20;</code> w = x<0 ? y=10 : z=20;</code>
- 
-===== switch structure ===== 
-  * [[selection_examples#switch|simple switch example]] 
-  * See Gaddis 4.14 (programs Pr4-23.cpp to Pr4-27.cpp). 
  
 ===== More about blocks and scope ===== ===== More about blocks and scope =====
cplusplus/control_structures_selection.txt · Last modified: 2017/01/31 23:57 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki