Dev Frank
2 min readJan 12, 2024

CONTINUE STATEMENT IN C

Continue is also a jump statement and a keyword in C language.

The "continue" statement is used in programming to skip the rest of the code inside a loop and move to the next iteration. When encountered, it jumps to the next iteration(Increment / Decrement) without executing the remaining code below it in the loop, allowing you to skip certain iterations based on a condition.

Unlike break statement that exits the loop if been encountered, continue skips some statements that is not needed to not to be displayed on the console.

Imagine you’re counting numbers in a loop. If you use the "continue" statement with a specific condition, it’s like saying, "Skip the current number and move to the next one." It helps you avoid certain actions in the loop for specific cases, making your code more flexible.

Certainly! Here's a simple example in C to illustrate the use of the continue statement:

#include <stdio.h>

int main() {
for (int i = 1; i <= 5; i++) {
// Skip printing even numbers
if (i % 2 == 0) {
continue; // Skip the rest of the loop and move to the next iteration
}
printf("%d\n", i);
}

return 0;
}

In this example, the loop runs from 1 to 5. When the loop encounters an even number, the continue statement is executed, skipping the printf statement and moving to the next iteration. As a result, only odd numbers are printed.

You can use continue in nested loops to skip the current iteration of the innermost loop while still allowing the outer loops to continue. The decision to use continue is based on a condition. It provides flexibility to skip certain iterations based on specific criteria, enhancing the control flow of your program.

The continue statement only makes sense within loop constructs like for, while, or do-while. It has no effect outside these loop structure. While it can make code more readable and concise, you can often achieve similar results without using continue by carefully structuring your loop conditions.

Dev Frank

Passionate tech enthusiast, diving deep into the world of software engineering. Thrilled to share insights with the world. A Software engineering student.