423,846 Members | 1,959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,846 IT Pros & Developers. It's quick & easy.

What is the purpose of a continue statement?

P: 7
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.
2 Weeks Ago #1
Share this Question
Share on Google+
1 Reply


P: 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.
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     int i;
  5.     for (i=0;i<=9;i++){
  6.     if (i == 3){
  7.         continue;
  8.     }else{
  9.         printf("%d\n",i);
  10.     }
  11.     }
  12. }
  13.  
1 Week Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.