4.8 while Iteration Statement

An iteration statement allows you to specify that a program should repeat an action while some condition remains true. The pseudocode statement


While there are more items on my shopping list
    Purchase next item and cross it off my list

describes the iteration during a shopping trip. The condition “there are more items on my shopping list” may be true or false. If it’s true, then the action “Purchase next item and cross it off my list” is performed. This action will be performed repeatedly while the condition remains true. The statement(s) contained in the While iteration statement constitute its body, which may be a single statement or a block. Eventually, the condition will become false (when the shopping list’s ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.