Iteration

Conditional statements play a very important role in programming. They are the workhorse of every program. But they cannot do the job alone. In every program, we deal with the situation when we have to repeat the same sequence of statements, for different customers, transactions, online clients, and so on. These tasks require iteration.

For repeated actions, C++ provides three iterative statements: while loops, do-while loops, and for loops. Each kind of C++ loop controls the repetition of a single statement (which ends with a semicolon) or a compound statement (block) enclosed in braces (and there is no semicolon after the closing brace of the block). To control iterations, all types of loops use logical expressions similar to logical ...

Get Core C++ A Software Engineering Approach 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.