Break and Continue in C++
Learn the use of break and continue statement using this c++ program.
#include<iostream>
using namespace std;
int main()
{
int i;
for(i=1;i<=10;i++)
{
if(i==4)
{
// 4 number is skipped.
continue;
}
if(i==9)
{
// loop breaks and control goes out of for loop
break;
}
cout<<i<<"\n";
}
return 0;
}
Output
1
2
3
5
6
7
8
Comments
Post a Comment