The continue Statement

  • The continue statement is used inside loop. When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration.
  • The continue statement causes an immediate jump to the top of a loop.
  • It also sometimes lets you avoid statement nesting.
  • The continue statement brings back program control to the start of the loop. You can use it for both ‘for’ and ‘while’ loops.

Syntax

continue;

Flow Diagram

Python continue statement

Example

#include <iostream>
using namespace std;

   int main()
    {
     int t;

     for(t=0; t<100; t++)
      {
       if(t%2)
        continue;
       cout << t << ' ';
     }
  return 0;
}

Output

 //Only even Numbers are printed



Ads