Home » Syntax References

Syntax of continue statement in C/C++ programming language



C/C++ programming language continue statement: what is break, when it is used and how, where t is used? Learn about continue statement with Syntax, Example.

continue is a keyword in C, C++ programming language and it is used to transfer the program’s control to starting of loop. It continues the execution of loop without executing the statements written after continue within the loop body.

Here, is the syntax of continue statement with loop statement in C/C++ programming:

for (counter_initialization; test_condition; counter_increment)
{
	//statement(s)
	if(test_condition)
		continue;
	//statement(s)
}

If the test_condition written within the loop body is true (non zero) value, statement(s) written after the continue will not print and program’s control will move to the beginning.

Consider the given example:

#include <stdio.h>

int main()
{
	int loop; //loop counter 
	
	for(loop =1; loop<=10; loop++)
	{
		if(loop==7)
		{
			printf("continue...\n");
			continue;
		}
		printf("%d\n",loop);
	}
	
	printf("BYE BYE!!!\n");
	
	return 0;
}

Output

1 
2 
3 
4 
5 
6 
continue... 
8 
9 
10
BYE BYE!!!

Consider the output, when value of loop is 7 program printed “continue...” written within the condition and without printing 7 (that value of loop at the time) program’s control reached to the starting of loop (i.e. to the loop’s test_condition).






Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.



Comments and Discussions


We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.