Section 3

Deciding

Comparing values, and making what the program runs depend on them.

Your programs now know how to hold a value and show it, but they still do the same thing on every run: the sequence of statements never varies.

This section gives them a choice. First comparing — where the question left hanging about the = sign finally gets its answer — then running one thing or another depending on the answer, and finally putting several conditions together.

In this section

  • 3.1Comparing

    The six comparisons, and the answer to the question left hanging about the = sign.

  • 3.2if and else

    Running one thing or another — and why a condition has to be a bool.

  • 3.3Combining conditions

    and, or, not, xor — written out in full, and only on bool values.