{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Simple Counting Loops - Simple Counting Loops Some loops do...

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

View Full Document Right Arrow Icon
9/22/09 Simple Counting Loops Some loops do NOT count: cout << “Input a number from 5 to 30:” << endl; cin >> x; while (x<5 or x > 30){ cout << “C’mon man, in range! Try again:” << endl; cin >> x;
Background image of page 1

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

View Full Document Right Arrow Icon
9/22/09 Simple Counting Loops Counting Loop: Iterative construct where a loop body is executed a certain amount of times while providing the loop body a counter to specify
Background image of page 2
9/22/09 Simple Counting Loops “For” Loop: Short hand form of the “while” loop. They take the form: for( initialization ; condition ; iteration_sta tement ) loop_body
Background image of page 3

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

View Full Document Right Arrow Icon
9/22/09 Simple Counting Loops Initialization : Statement establishing the truth of the invariant before the execution of the loop. Condition (continuation): Expression that repeats until it evaluates to False. Iteration_statement (counter): Expression that continues to change the initial declared value.
Background image of page 4
9/22/09 Simple Counting Loops Basic example: for( n =9 ; n<N ; n = n + 8 ){ Get something done } -Which is Initialization?
Background image of page 5

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

View Full Document Right Arrow Icon
9/22/09 Simple Counting Loops Basic example: for( n =9 ; n<N ; n = n + 8 ){ Get something done } -Which is the condition?
Background image of page 6
Background image of page 7

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

View Full Document Right Arrow Icon
Background image of page 8
Background image of page 9

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

View Full Document Right Arrow Icon
Background image of page 10
Background image of page 11

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

View Full Document Right Arrow Icon
Background image of page 12
Background image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}