4 Ways To Structure a Program 1. Sequence 2. Selection 3. Looping 4. Functions while loop -input failure control while( !in.fail() ) -counting loops -summing loops for loop Example: for ( int i=0; i<10; i++ ) { //loop body } int i=0;//initialization while( i< 10 )//test { //loop body i++;//modification } do-while - post-test loop int x; do { cin >> x; } while( x % 2 != 0 ); Functions A named block of code 3 Pieces: 1. header or signature: a. return type b. name c. parameter list 2. definition a. this is where we write our function 3. calling the function //this function will tell me //if a number is odd or even //a return of true means //the number was even //therefore false means odd bool oddOrEven( int number );//signature or header //notice it ends with a ; ^ //function definition bool oddOrEven( int number ) //<-------no semicolon here { bool answer = false; if ( number % 2 == 0 ) answer = true; return answer; }