Chapter 6
Making Decisions with Flow Control
The programs that we have been writing until now have been very linear. That is, they begin with the first line in main and carry on executing each line at a time until the program finishes with the return statement on the last line of main. Sometimes we might decide to carry out different code paths based on values we have stored in variables or repeat a section of code until some condition is satisfied.
C++ provides us with statements that allow us to carry out these decisions and repetitions. This chapter introduces the if, switch, for, and while statements. These statements collectively are known as the flow control statements. We'll end the chapter by using flow control statements to add ...
Get Learn C++ for Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.