continue statement or continue keyword

In C++ programming language the continue statement skips below code of current block and shifts program control to the next iteration of the loop. 
C++ प्रोग्रामिंग लैंग्वेज में कंटिन्यू स्टेटमेंट का प्रयोग, वर्तमान एक्सीक्यूशन को रोक कर, प्रोग्राम कंट्रोल को अगले चरण के  प्रारंभ पर भेजने के लिए किया जाता है। 
For the for loop, continue statement causes the updation part of the loop to execute. 
फॉर लूप में यह प्रोग्राम कंट्रोल को लूप के अपडेशन भाग पर भेजता है। जबकि  
For the while and do...while loops, continue statement causes the program control to shift to the condition part of the loop.
व्हाइल लूप एवं डू व्हाइल लूप में यह प्रोग्राम कंट्रोल को लूप के कंडीशन भाग पर भेजता है। 

Syntax:-   continue;

Example:-
1.) C++ program for continuing in for loop.
#include<iostream.h>
void main(){
int i;
cout<<"Counting  from 1 to 10"<<endl;
for(i=1;i<=10;i++){
if(i==5) continue;
cout<<i<<" ";
}
}

output:- 1 2 3 4 6 7 8 9 10

2.) C++ program for continuing in while/do while loop.
#include<iostream.h>
void main(){
int i=1;
cout<<"Counting  from 1 to 10"<<endl;
while(i<=10){
if(i==5) continue;
cout<<i<<" ";
i++;
}
}

output:- 1 2 3 4..........

No comments:

Post a Comment