Chapter 7: Exploring Loops and Iterations
Some operations need to be repeated one or more times before their result is completely evaluated. The code to be repeated could be copied the required number of times, but this would be cumbersome. Instead, for this, there are loops – for()…
, while()…
, and do … while()
loops. Loops are for statements that must be evaluated multiple times. In this chapter, we will explore C loops. After considering loops, we'll move on to the much-maligned goto
statement.
The following topics will be covered in this chapter:
- Understanding brute-force repetition and why it might be bad
- Exploring looping with the
while()…
statement - Exploring looping with the
for()…
statement - Exploring looping with the
do … while()
statement - Understanding when you would use each of these looping statements
- Understanding how loops could be interchanged, if necessary
- Exploring the good, the...