C++ Continue
C++ continue Statement
The continue statement forces to iterate the loop instantly without executing the next statement of the loop. Sometimes it is required to skip certain test condition within the loop, in such case continue statement is applied. When continue statement is applied inside the nested loop, it only affects (iterate) the inner loop.Syntax
Output:
continue;
Example
#include <iostream>
using namespace std;
int main()
{
for (int i = 0; i < 10; i++) {
if ( i == 6 || i == 9){
continue;
}
cout << i << " ";
}
cout << endl<<"output of inner loop"<<endl;
//continue within inner loop
for (int j = 0; j < 2; j++) {
for (int k = 0; k < 5; k++) {
if (k == 3){
continue;
}
cout << j << k << " ";
}
}
}
0 1 2 3 4 5 7 8 output of inner loop 00 01 02 04 10 11 12 14