Continue Statement in C

Level 390 keystrokes

Uses continue to skip printing when i equals 3.

C code

// Loop over 1 to 5
1for (int i = 1; i <= 5; i++) {
// Only the value 3 is skipped
2 if (i == 3) {
// Skip the rest of this pass and go to i++; unlike break, the loop goes on
3 continue;
4 }
// Not reached when i is 3
5 printf("%d ", i);
6}
// End the line: 1 2 4 5
7printf("\n");

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
  • )× 4
  • =× 4
  • {× 2
  • }× 2
  • +× 2
  • ,× 1
  • \× 1

More C examples at level 3

← C typing practice