What is the purpose of a continue statement?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • c0d3rX
    New Member
    • Nov 2018
    • 7

    What is the purpose of a continue statement?

    Does anyone have any good coding examples which use a continue statement. I'm fairly new to C programming and am unfamiliar with continue statements.
  • Jason4567
    New Member
    • Dec 2018
    • 2

    #2
    Definition:The continue statement in C programming forces the next iteration of the loop to take place, skipping any code in between.
    Here is also a simple example:
    If you run it you will notice that the 3 number is not printed because we have made a condition that if i = 3 then it skips this i and moves to the next i and it prints it.
    Code:
    #include <stdio.h>
    
    int main(){
        int i;
        for (i=0;i<=9;i++){
    	if (i == 3){
    	    continue;
    	}else{
    	    printf("%d\n",i);
    	}
        }
    }

    Comment

    Working...