Posted By:
2 Jul, 2013 6:42 am PDT

continue statement in C++

What do you mean by continue? What is the use of it?

The continue statement causes the program to skip the rest of the loop in the current iteration as if the end of the statement block has been reached, causing it to jump to the start of the next iteration.

For Eg: 


int main()


int n;


for(int i=0;i<n;i++) ←————←                      

{                                                         |

cout<<i+1<<”\t”;                           |

if(i==5)                                             |

   continue;                ————→


cout<<”\nEnd of loop”;



The Output of the above example is:

1 2 3 4 6 7 8 9 10

End of loop


Was it useful?  

Please login to reply to this problem.