Chapter 3. Control Structures
In This Chapter
Getting used to conditions
Using if, else if, and else
Using switch structures
Working with while and for loops
Using comparison operators
Introducing Conditions (Again)
Computer programs make decisions. That's part of what makes them interesting. But all the decisions a computer seems to make were already determined by the programmer. The computer's decision-making power is all based on an idea called a condition. This little gem is an expression that can be evaluated as true or false. (That sounds profound. I wonder if it will be on the mid-term?)
Conditions can be comparisons of one variable to another, they can be Boolean (true or false) variables, or they can be functions that return a true or false value.
If this talk of conditions is sounding like déjà vu, you've probably read about conditions in Book IV, Chapters 2 and 3. You'll find a lot of the same ideas here; after all, conditions (and branches and loops, and lots of other stuff) are bigger than one programming language. Even though this mini-book covers a different language, you'll see coverage of the same kinds of things. If you haven't read ...