Summary
From this chapter, we learned that we can not only alter program flow with function calls but also execute or omit program statements through the use of conditional statements. The if()… else…
statement has a much wider variety of forms and uses. The switch()…
statement operates on a single value, comparing it to the desired set of possible constant values and executing the pathway that matches the constant value. if()… else…
statements can be chained into longer sequences to mimic the switch()…
statement and to provide a richer set of conditions than possible with switch()…
. Also, if()… else…
statements can be nested in one or both clauses to either make the purpose of that branch clear or the condition for each pathway less complex.
In these conditional statements, execution remains straightforward, from top to bottom, where only specific parts of the statement are executed. In the next chapter, we'll...