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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.