Académique Documents
Professionnel Documents
Culture Documents
5th Edition
Chapter 5
Looping
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education.
All Rights Reserved
Topics
5.1 The Increment and Decrement Operators
5.2 Introduction to Loops: The while Loop
5.3 Counters
5.4 Letting the User Control the Loop
5.5 Keeping a Running Total
5.6 Sentinels
x = ++y; // y is incremented to 2
// Then 2 is assigned to x
cout << x
<< " " << y; // Displays 2 2
x = --y; // y is decremented to 1
// Then 1 is assigned to x
cout << x
<< " " << y; // Displays 1 1
false
condition
true
statement(s)
statement(s)
true
condition
false
update
code
false
test
true
statement(s)
Chapter 5
Looping
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education.
All Rights Reserved