By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,777 Members | 1,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,777 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.
Nov 24 '18 #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>
  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. }
Dec 2 '18 #2

Post your reply

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