So far, the programs you’ve seen have been linear—each statement executes, in order, from top to bottom. However, to create interesting games, you need to write programs that execute (or skip) sections of code based on some condition. That’s the main topic of this chapter. Specifically, you’ll learn to:
Understand truth (as C++ defines it)
if statements to branch to sections of code
switch statements to select a section of code to execute
do loops to repeat sections of code
Generate random numbers
Truth is black and white, at least as far as C++ is concerned. You can represent true and false with their corresponding keywords,
false. You ...