BREAK : The break command allows you to terminate and exit a loop or switch command from any point other than logical end.
CONTINUE : The continue statement passes control to the next iteration and left those value who comes under its condition.
SOURCE CODE
// BREAK AND CONTINUE IN C++.
#include <iostream>
using namespace std;
int main()
{
cout<<"___BREAKS IN C++___"<<endl;
cout<<endl;
int a;
for (int a = 0; a <= 33; a++)
{
cout << a << endl;
if (a>=2)
{
break; //break kya krega yhn pe program ko rok dega.
}
}
cout<<"____CONTINUE IN C++____"<<endl;
cout<<endl;
for(int a = 0; a<=9; a++ )
{
if(a==3){
continue; //continue kya krega srif jb a==3 hoga usko chod dega and baaki run hogga.
}
cout<<a<<endl;
}
return 0;
}
//OUTPUT
// ___BREAKS IN C++___
// 0
// 1
// 2
// ____CONTINUE IN C++____
// 0
// 1
// 2
// 4
// 5
// 6
// 7
// 8
// 9
Comments
Post a Comment