Program Control Statements
I.	Selection Statements
A.	The if statement
	1. 	standard form
		 if(expression)
		{
			statement
		}
		else
		{
			 statement
		}
	2.	the conditional
		a.  0 = FALSE, and all others = TRUE
	3.	nested if
		a.  allows 256 levels of nesting
	4.	if-else-if ladder
		a.	structure
			if (condition)
				statement;
			else if(condition)
				statement;
			else
				statement;
		b.  as soon as a true condition is found the statement is executed and the 		rest is bypassed
B.	The switch statement
	1.  standard form
		a.	switch(expression
			{
				case constant1:
					statement
					break;
				case constant2:
					statement
					break;
				default
					statement
			}
		b.  switch expression must be evaluated to character or integer
		c.	default performed if no matches
		d.  when a matfch is found, executed until reach break
		e.	important characteristics
			1.  switch can only test for equality
			2.	no two case constants can have the same value
			3.	usually more efficient than nested if
			4.	statement sequences with each case are not blocks
			5.	can have 16,384 cases
			6.	can have empty cases
		f.	nested switch statements
	
II.	Iteration Statements
A.	The for loop
	1.	standard form
		a.	for (initialization;expression;increment)
			{
				statement
			}
	2.  continues as long as the conditional expression tests true
	3.  once a false encountered will continue on the block following for loop
	4.	variations on the for loop
		a.	for(initialization1,initialization2;expression1, expression2)
			{
				statement1
				statement2
			}
		b.	leave out increment portion
		c.	put initialization section outside of loop
		d.	put increment portion inside body
		e.	the infinite loop
			1.  standard form
				a.	for(;;)
					{
						//...
					}
		f.	time delay loops
			1.  standard form
				a.	for(initialization;condition;increment) ;
			b.	semicolon is empty statement that terminates the program

B.	The while loop
	1.  standard form
		a.	while(expression)
			{
				statement;
			}
	2.	terts condition before entering the loop

C.	The do-while loop
	1.	standard form
		do
		{
			statements;
		}
		while(expression);
	2.	checks its condition at the bottom of the loop
	3.	executes as long as condition expression is true

D.	Nested loops
	1.	up to 256 levels

III.	Jump Statements
A.	continue
	1.	used to force an early iteration of a loop
	2.  skips any code between itself and the conditional code that controls the loop
		a.  in while and do-while  goes directly to conditional and then continues 			loop
		b.	in for increments, then conditional executed, then continues
B.	break
	1.	used to force an immediate exit from a loop
	2.	used when special condition can cause immediate termination
C.	goto
	1.  not used too often
	2.  requires a label, which is a valid C++ identifier followed by a colon
D.	return


Back to the Main Menu