Continue In C++


If we want to skip some statement in the loop then we can use there continue statement. It mostly used when we want to skip the rest of the statement in the current loop and start from the top again.


Simple example of continue statement in c++


#include<iostream>

using namespace std;

int main(){

int i=1;

clrscr();

for(i=1;i<=5;i++)

{

if(i==4)

{

continue;

}

cout<<“Welcome %d\n”,i;

}

cout<<“Exit from loop here”;

return0

}


Output:
welcome 1
welcome 2
welcome 3
welcome 4
welcome 5
Exit from loop here