2.12 ITERATION STATEMENTS

In this part, we will see the statements, which can loop around. This process is termed as iteration. Iteration means the act of repeating a process usually with the aim of approaching a desired goal or target or result. Each repetition of the process is also called “iteration”. The result of iteration is used as the starting point for the next iteration. Such statements will increase the power of computer tremendously. Let us start with very popular statement called “for statement”.

2.12.1 for statement

The for statement is most useful control statement. It allows us to repeat a statement (or a block) for number of times. The general format of for statement is as follows:

for ( expression1; expression2; expression3) ...

Get Object Oriented Programming with C++, Second Edition 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.