Nmc_header
Search:  Signup to RSS feed
 Subscribe
Share/Save/Bookmark

Flow Control

C Programming Language>

Mind Map branch: Flow Control (null) Flow Control loops (null) while statement Syntax while ( expression )
 statement Driving Factors Before the Loop Initialization In the Loop Modification value that affects the loops expression Within expression while ( ++variable )
 statement After expression while ( expression )
........
........
++variable Counter Variable Holds Value of # of loops Termination causes loop to terminte a condition purpose repeated execution of a statement or statement block as long as expression is true for statement syntax for ( expression1 ; expression2 ; expression3 )
statement Initialization expression1 evaluated once - beginning Termination expression2 evaluated each time - beginning Modification expression3 evaluated each time - bottom - post statement execution infinite loop for ( ; ; )
DoSomethingForever() no initialization, termination, and modification considered bad form comparison for loop as while loop expression1;
while ( expression2 ) 
{
   statement
   expression3;
} for loop and while loop are interchangable do statement syntax do
  statement
while ( expression ) ; comparison unlike while and for loop expression is evaluated at the bottom of loop consequence of bottom evaluation loop statement always executed at least once selection statements (null) if statement Types Regular (no else) Syntax if (expression)
statement Statements are executed/triggered only if expression evaluates to "not false" If with else Syntax if ( expression )
statement
else
statement if expression = not false execute statements after expression and ignore statements after else if expression = false execute statements after else Value "If statement expressions" can evaluate to false or not false false and not false have values If the expression evaluates to  0 expression is false If Statment is not triggered If expression does not evaluate to 0 expression is not false If Statement is triggered Purpose One time execution of a statement or statement block based on value of expression switch statement syntax switch ( expression )
{
case value1:
 statement
 break;
case value2:
 statement
 break;
case valueX:
 statement
 break;
default:
 statement
} case value has to be constant or single-byte characters case value cannot be a variable or mutiple-byte character strings purpose uses value of expression to determine which case is executed case with no statements used to make two cases execute the same statement switch ( numberOfEggs ) 
{
case 1:
case 2:
HardBoilThem();
break;
case 3:
MakeAnOmelet();
default:
} case 1 and 2 will execute the same statement - break is missing in case 1 break statement and fall-through not adding breaks in the cases adds more functionality as you fall-through the cases switch ( myVar ) 
{
case 1:
DoSometimes();
case 2:
DoFrequently();
default:
DoAlways();
} if myVar is case1 all functions get executed if myVar is case2 then functions in this case and default get executed if myVar case is not 1 or 2 then function after default get executed

Hyperlinks

Map Branches

Comments

0 map comments of 0 total for this map