Chapter 5. Using Compound Assignment and Iteration Statements
After completing this chapter, you will be able to
Update the value of a variable by using compound assignment operators.
Write while, for, and do iteration statements.
Step through a do statement and watch as the values of variables change.
In Chapter 4, you learned how to use the if and switch constructs to run statements selectively. In this chapter, you’ll see how to use a variety of iteration (or looping) statements to run one or more statements repeatedly.
When you write iteration statements, you usually need to control the number of iterations that you perform. You can achieve this by using a variable, updating its value as each iteration is performed, and stopping the process when ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access