2. Decisions, Decisions

If you’ve worked through Chapter 1, you’ve already begun to do real programming: getting input, crunching numbers, and printing output. But to really do anything interesting, you have to give the program the ability to make decisions. IF this, THEN do that, and so on.

Computers don’t really make the decisions the way humans do (not without Artificial Intelligence, a topic I discuss on page 31). Like everything else in a program, decisions must be absolutely clear and precise, and depend on the result of comparing two numbers. And yet, upon such simple decisions, it’s possible to build complex, interesting, and rich behavior.

But First, a Few Words about Data Types

You can think of a variable as a magic box or a bucket ...

Get C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Third 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.