Sometimes it is necessary in the program to execute the statement several times, and C++ loops execute a block of commands a specified number of times until a condition is met. In this post, you will learn about all the looping statements of C++ along with their use.

Loops in C++

There may arise some situations during programming where programmers need to execute the block of code several times (with slight variations sometimes). In general, statements get executed sequentially with a C++ program, one statement followed by another. C++ provides statements for several control structures along with iteration/repetition capability that allows programmers to execute a statement or group of statements multiple times.

C++ supports following types of loops:
  • while loops
  • do while loops
  • for loops


All are slightly different and provides loops for different situations.

Figure – Flowchart of Looping:

C++ Loop Control Statements

Loop control statements are used to change the normal sequence of execution of a loop.

Statement Syntax Description
break statement break; Is used to terminate loop or switch statements.
continue statement continue; Is used to suspend the execution of current loop iteration and transfer control to the loop for the next iteration.
goto statement goto labelName;labelName: statement; It transfers current program execution sequence to some other part of the program.