C Programming Continue Statement
Last modified by Microchip on 2023/11/09 09:06
The continue statement causes programs to jump back to the beginning of a loop without completing the current iteration.
Syntax
continue;
1 int i = 0;
2
3 while (i < 5)
4 {
5 i++;
6 if (i == 2) continue; //Skip remaining iteration when i=2.
7 printf("Loop iteration %d\n", i);
8 }
2
3 while (i < 5)
4 {
5 i++;
6 if (i == 2) continue; //Skip remaining iteration when i=2.
7 printf("Loop iteration %d\n", i);
8 }
The expected output for this loop is:
Loop iteration 1
Loop iteration 3
Loop iteration 4
Loop iteration 5
Loop iteration 3
Loop iteration 4
Loop iteration 5