Continue Statement in C++

Level 273 keystrokes

Loops i from 1 to 5 and uses continue to skip the iteration where i is 3, so it prints 1, 2, 4 and 5.

C++ code

// Counts i from 1 to 5
1for (int i = 1; i <= 5; i++) {
// When i is 3, continue skips the rest of the body and goes on with i++
2 if (i == 3) continue;
// Prints every value except 3
3 cout << i << endl;
4}

Output

1
2
4
5
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this C++ code and how often they appear.

  • <× 5
  • ;× 4
  • =× 4
  • (× 2
  • )× 2
  • +× 2
  • {× 1
  • }× 1

More C++ examples at level 2

← C++ typing practice