Chapter 7: Advanced Control Flow I

Chapter Goals

Multiple Alternatives

Multiple Alternatives (Coins Flowchart)

Multiple Alternatives (coins5.cpp)

Multiple Alternatives (richter.cpp)


Nested Branches

If your status is Single and
if the taxable income is over
but not over the tax is of the amount over
$0 $21,450 15% $0
$21,450 $51,900 $3,217.50 + 28% $21,450
$51,900
$11,743 + 31% $51,900

If your status is Married and
if the taxable income is over
but not over the tax is of the amount over
$0 $35,800 15% $0
$35,800 $86,500 $5,370.00 + 28% $35,800
$86,500
$19,566.00+ 31% $86,500

Nested Branches (tax.cpp)


Boolean Operations



DeMorgan's Law


The for Loop

Syntax 7.1: for Statement

Syntax 7.1 : for Statement

for (initialization_expression; condition; update_expression) statement
Example:
for (int i = 1; i <= 10; i++) sum = sum + i;
Purpose: Execute the initialization statement. While the condition remains true, execute the statement and update the expression.

The for Loop (forfac.cpp)