C continue Statement In Hindi

📔 : C 🔗

C में continue का use किसी दी गयी condition के according while loop , for loop iteration को skip करने के लिए किया जाता है। और skip करने के बाद Loop next iteration से Start हो जाता है। simply हम कह सकते हैं कि C में Continue का use हम वहाँ करते हैं जब हमें किसी condition पर loop execution को skip करना हो।

? continue statement loop execution को terminate नहीं करता है current iteration को skip करता है-

c continue statement example

CopyFullscreenClose FullscreenRun
#include <stdio.h>
int main() {
  for(int x=1; x <= 5 ; x++) {
    // skip when value of x is 3.
    if(x==3) {
      continue;
    }  
    printf("%d\n", x);
  }
  return 0;
}
Output
1
2
4
5

Example में आप देख सकते हैं कि x की value 3 होते ही वो level skip होकर next iteration start हो गयी।

? well , well , C में continue statement JavaScript, PHP से थोड़ा अलग होता है क्योंकि PHP और JavaScript में continue statement के साथ argument भी pass कर सकते हैं , जो define करता है कि एक बार में कितने loop skip करने हैं। लेकिन C में ऐसा नहीं है , यह continue के साथ कोई argument pass नहीं होता है। यह जिस loop में use होगा उसी की iteration को skip करता है।

C continue with while loop

CopyFullscreenClose FullscreenRun
#include <stdio.h>
int main() {
  int x = 0;
  while(x < 5) {
    x++;
    // now check condition.
    if(x==3) {
      continue;  
    }
    printf("%d\n", x);
  }
  return 0;
}
Output
1
2
4
5

Important

  • while loop में continue statement current loop execution skip करके वापस condition पर जाता है।

  • for loop में continue statement current loop execution skip करके वापस updated iteration पर जाता है।

continue का use किसी loop के अंदर ही कर सकते हैं , normal statements या if else के साथ आप break use नहीं कर सकते हैं।
For Example -

#include <stdio.h>
int main() {
  int x = 2;
  if(x==3) {
    continue;  
  }
  return 0;
}

error: continue statement not within a loop

I Hope, आपको C language में continue statement के बारे में अच्छे से समझ आया होगा।

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers