Sometimes it is necessary to execute some statements multiple times in a program; C++ loops execute a block of statements a certain number of times until a condition is met. In this tutorial, you will learn how to use various looping statements in C++.
What are Loops in C++?
Some situations may arise during programming where the programmer needs to execute a block of code multiple times (sometimes with slight changes). Generally, statements in C++ get executed sequentially (one statement followed by another). C++ provides statements for several control structures and iteration capability, allowing programmers to execute a statement or group of statements multiple times.
All are slightly different and provide loops for use in different situations.
Figure - Flowchart of Looping:
C++ Loop Control Statements
Loop control statements change the normal sequence of execution of the loop.
|break statement||It terminates the loop or switch statement.|
|continue statement||It suspends the execution of the current loop iteration and transfers control to the loop for the next iteration.|
|goto statement||It transfers the current program execution sequence to some other part of the program.|