continue Statement in C

For Complete YouTube Video: Click Here

In this class, we will understand the ‘continue’ Statement in C.

Continue is a jump statement.

We have already discussed the break statement.

continue Statement

Similar to the break statement, we will use the continue statement in the loops.

The ‘continue’ statement transfers control just before the end of the loop body.

The only difference between the break and continue is that the compiler will transfer the control after the end of the loop in a break statement.

Whereas in continue, the compiler will transfer the control just before the end of the loop.

continue Statement Example

The image below is the programming example to understand the ‘continue’ statement.

continue Statement in C Example
continue Statement in C Example

The above program is to count a series of 5 integers given by the user. If the user provides zero as the input, then the number of inputs should not be incremented.

The program will count only non-zero inputs as the inputs.

The while loop in the program will iterate until the user gives the five non-zero inputs.

The if statement in the while loop is true if the input given by the user is zero.

In that case, the ‘continue’ statement will get executed.

As continue is getting executed, the compiler will jump the program execution to just before the end of the loop, and the loop will iterate again.