0
Continue statement in C++
Guys please tell me the usage of continue statement and how it is different from break statement?
3 Antworten
+ 5
Example of continue
#include <iostream>
Using namespace std;
Int main();
For(int I=0;I<=5;I++)
If(I==3)
Continue;
Cout<<I<<endl;
Output:
0
1
2
4
5
+ 3
continue skips the rest of the code and starts from the top of the loop.
break - breaks out of the loop or you could say exits the loop.
+ 3
Break completely stops the loop, whereas continue just skips the current iteration, and goes back to the top.