The continue statement breaks one iteration (in the loop) if a specified condition occurs, and continues with the next iteration in the loop.The difference between continue and the break statement, is instead of "jumping out" of a loop, the continue statement "jumps over" one iteration in ...
Thecontinuestatement stops the current iteration in thedo...whileloop and continue with the next. Example Stop, and jump to the next iteration if$iis 3: $i=0;do{$i++;if($i==3)continue;echo$i;}while($i<6); Try it Yourself » ...
Thebreakstatement can also be used to jump out of a loop: Example for(leti =0; i <10; i++) { if(i ===3) {break; } text +="The number is "+ i +""; } Try it Yourself » In the example above, thebreakstatement ends the loop ("breaks" the loop) when the loop counter...
if(i ==4) { i++; continue; } cout << i <<"\n"; i++; } Try it Yourself » Exercise? What does thebreakstatement do in a loop? Exits the loop immediately Skips the current iteration Repeats the current iteration Submit Answer »...
You have already seen thebreakstatement used in an earlier chapter of this tutorial. It was used to "jump out" of aswitchstatement. Thebreakstatement can also be used to jump out of aloop. This example stops the loop when i is equal to 4: ...