Chapter 7: Advanced Control Flow II

Chapter Goals

The do Loop

The do Loop (sqroot.cpp)

Syntax 7.2: do/while Statement

do statement while (condition);
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)

Processing Text Input

Processing Text Input (words.cpp)


Simulations (dice.cpp)

Simulations (Buffon Needle Experiment)

Simulations (buffon.cpp)