- 6.1 Control Structures, Blocks, and Compound Statements
- 6.2 Conditionals
- 6.3 Loops
- 6.4 What You Should Know
6.4 What You Should Know
"Two roads diverged in a wood, and I—" wrote Robert Frost. This chapter was about making decisions about the flow of your program, what road to take, how to repeat a sequence of statements, and how to stop the repetition. At this point, you should understand:
- How to use conditional constructs to control the flow of your program; if/else, switch, and so on.
- What a block is and when to use curly braces.
- How and why you would use a switch statement.
- How the while and the do/while loops differ.
- How to use a for loop.
- How to use break and continue with loops.
- The purpose of nested loops.
- How to make an infinite loop and how to get out of it.
- The purpose of labels in loops.
- How else/ifs work.