C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C continue statementThe continue statement in C language is used to bring the program control to the beginning of the loop. The continue statement skips some lines of code inside the loop and continues with the next iteration. It is mainly used for a condition so that we can skip some code for a particular condition. Syntax://loop statements continue; //some lines of the code which is to be skipped Continue statement example 1#include<stdio.h> void main () { int i = 0; while(i!=10) { printf("%d", i); continue; i++; } } Output infinite loop Continue statement example 2#include Output 1 2 3 4 6 7 8 9 10 As you can see, 5 is not printed on the console because loop is continued at i==5. C continue statement with inner loopIn such case, C continue statement continues only inner loop, but not outer loop. #include Output 1 1 1 2 1 3 2 1 2 3 3 1 3 2 3 3 As you can see, 2 2 is not printed on the console because inner loop is continued at i==2 and j==2.
Next TopicC goto statement
|