Chapter 7: Advanced Control Flow II

Chapter Goals

The do Loop

The do Loop (sqroot.cpp)

The do Loop (Syntax 7.2: do/while Statement)

Syntax 7.2: do/while Statement

do statement while (condition);
Example:
do x = sqrt(x); while (x >= 10);
Purpose: Execute the statement, then test the condition, and repeat the statement while the condition remains true.

Nested Loops

Nested Loops (table.cpp)

Nested Loops


Processing Text Input

Processing Text Input (words.cpp)


Simulations

Simulations (dice.cpp)


Simulations (Buffon Needle Experiment)

Simulations (buffon.cpp)