Continue Statement In C++ With Example

Card image cap

Continue Statement ?

Continue statement is used to skip the remaining statement in the loop. The general format is:continue;
Continue is also a loop control statement just like the break statement. continue statement is opposite to break statement where in, Continue statement forces to execute the next iteration of the loop instead of terminating the loop.


Continue Statement :

In real practice, Continue statement is almost always used inside the body of conditional statement (if...else) inside the loop.

Basically Continue statements are used in the situations when we are not sure about the actual number of iterations for the loop or we want to terminate the loop based on some condition.


Card image cap

Example 1:



Output :

    	0 1 2 4 5 6
Card image cap

Example 2:



Output :

    5
	00 01 02 04 10 11 12 14
Card image cap