O'Reilly logo

C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Third Edition by Brian Overland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3. And Even More Decisions!

Building on simple decision-making structures, Chapter 2, “Decisions, Decisions,” showed how computers can do complex and interesting things, such as play a game, repeat an operation a set number of times, and perform mathematical operations.

Critical to these operations are something called control structures—a set of keywords (if, else, while) and associated grammar—that control what the program does next. These control structures, nearly all inherited from C, include just a few simple but extremely versatile keywords. This chapter introduces two more: do-while and switch.

Remember that by controlling what the program does next, you control the program! It’s that simple.

The do-while Loop

If you’ve worked through ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required