Easy Tutorial
❮ Cpp Function Call By Reference Cpp Operators ❯

C++ continue Statement

C++ Loops

The continue statement in C++ is somewhat similar to the break statement. However, instead of forcing termination, the continue statement skips the current iteration of the loop and forces the next iteration to occur.

For for loops, the continue statement causes the condition test and increment section to be executed. For while and do...while loops, the continue statement causes the program control to return to the condition test.

Syntax

The syntax for the continue statement in C++:

continue;

Flowchart

Example

#include <iostream>
using namespace std;

int main ()
{
   // Local variable declaration
   int a = 10;

   // do loop execution
   do
   {
       if( a == 15)
       {
          // Skip the iteration
          a = a + 1;
          continue;
       }
       cout << "Value of a: " << a << endl;
       a = a + 1;
   }while( a < 20 );

   return 0;
}

When the above code is compiled and executed, it produces the following result:

Value of a: 10
Value of a: 11
Value of a: 12
Value of a: 13
Value of a: 14
Value of a: 16
Value of a: 17
Value of a: 18
Value of a: 19

C++ Loops

❮ Cpp Function Call By Reference Cpp Operators ❯