Chapter 5
Directing the Application Flow
IN THIS CHAPTER
Comparing numbers and evaluating other conditions
Doing things based on a comparison
Repeating code in specific ways
Creating nested loops (loops within loops)
As you program in C++, many times you need to present the computer with a choice, allowing it to do one thing in one situation and something else in another situation. For example, you may have an application that asks for a user’s password. If the password is correct, the application continues; but if the password is incorrect, the application asks the user to reenter the password. After some number of times — usually three — the application performs yet another task when the user enters the incorrect password. Such situations are called conditions. In the case of the password, the condition is whether the password is correct.
You may also encounter situations in which you want several lines of code to run over and over. These are loops, and you can specify conditions under which the loop runs. For example, you may want to check the password only three times; and ...
Get C++ All-in-One For Dummies, 4th Edition 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.