208 Day 09 repititon2

208 Day 09 repititon2 - 4002-208Intro. to Prog. [in C++]Day...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 4002-208Intro. to Prog. [in C++]Day 09More on RepetitionObjectives•Review while loop•for loop•Auto increment operator•Accumulator•Compound operator4002-2082Review of while loopwhile (loop condition){loop body}•Loop condition is a Boolean condition.•Execute loop body if loop condition is true.4002-2083Use a Sentinel Loop//read first input valuewhile (input is invalid){//execute code//read another input value}4002-2084Finger work•Run the program grades.cpp•Add a data validation loop to ensure score is between 0 and 100, inclusively.4002-2085for loop•Most common use is to execute the loop body a specific number of times•Basics–Initialize counter–Test counter – halt loop when test is false–Change counter•for(initialize counter; test counter; change counter)4002-2086Perform code a specific number of timesfor ( int counter = 1 ;counter <= number_of_times ;counter=counter+1 ){//code to repeat}4002-2087Print 1 to 10•Initialize counter: int k = 1Test counter: k<=10•Change counter: k=k+1•for (int k=1; k<=10; k=k+1){cout << k << endl;}4002-2088Counter...
View Full Document

This note was uploaded on 03/31/2009 for the course NSSA 4002 208 taught by Professor Niemi during the Spring '09 term at RIT.

Page1 / 15

208 Day 09 repititon2 - 4002-208Intro. to Prog. [in C++]Day...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online