continue

Passes control to the next iteration of the nearest enclosing do, for, or while statement in which it appears, bypassing any remaining statements within that code block.

 

#include <iostream>
using namespace std ;

int main () {

	for (int myVar = 0 ; myVar < 7 ; myVar++) {

		if (myVar == 3)
			continue; //when myVar equates to 3, the loop will carry out the next iteration
				   //bypassing the remaining statements within its code block
		cout << "myVar is now: " << myVar << endl ;
	}
	return 0;
}

Compile & Run:

myVar is now: 0
myVar is now: 1
myVar is now: 2
myVar is now: 4
myVar is now: 5
myVar is now: 6

Leave a Reply