Break can leave the program block of the current switch, for, while, and do, and advance to the next statement after the block, which is used primarily to interrupt the next case comparison in switch. It is used primarily to interrupt the current loop execution in for, while, and do.
The Continue function is similar to break, which is used primarily for loops, except that break ends the execution of the block, and continue only ends the statement of the block after it, and jumps back to the beginning of the loop block to continue to the next loop instead of leaving the loop.
1.include<iostream>
using namespace std;
int Main ()
{
int i=0 ;
while ( i<3)
{
i++ ;
if ( i==1)
break ;
The value of cout<< "I" is: "<<i< <endl;
}
&NBSP; return 0;
} 11> c21> c31> c41> c51> Output Result: (empty)
2.include<iostream>
using namespace std;
int main ()
{
int i=0;
while ( i<3)
{
i++ ;
if ( i==1)
continue;
cout< < "I is the value of:" <<i<<endl;
}
&NBSP; return 0; Output Result: The value of I is: 2
&NBSP; } The value of I is: 3
Break and continue differences and use occasions