Continue statement in C

continue statement is a keyword and we use continue statement inside the loops only.

Why we use Continue statement?

If you want to skip the current iteration of the loop and want to begin the next iteration then we use continue statement.

Syntax of continue statement:

	
    continue;
    

Example of continue statement:


	#include<stdio.h>
	#include<conio.h>

	void main()
	{
		int i;
		clrscr();

		for(i=1; i<=10; i++)
		{
			if(i==5)
			{
			continue;
			}
			printf("%d\n",i);
		}

		getch();
	}

Output:

	
    1
    2
    3
    4
    6
    7
    8
    9
    10
    

Now understand the working of the program

In above example we are skipping the iteration number 5 with the help of continue statement. This is the use of continue statement.

Post Your Comment