In C programming, the continue statement is used to skip the current iteration of a loop and move to the next iteration. When a continue statement is encountered inside a loop, it skips the remaining code inside the loop for that particular iteration and proceeds with the next iteration of the loop.
continue;
In C programming, you can use the continue statement to skip certain iterations in a loop. If you want to skip even numbers in a for loop, the continue statement can be used inside the loop to bypass the rest of the loop’s body whenever an even number is encountered.
#include <stdio.h>
int main() {
// Loop from 1 to 10
for (int i = 1; i <= 10; i++) {
// Check if the number is even
if (i % 2 == 0) {
continue; // Skip the rest of the loop for even numbers
}
// Print odd numbers
printf("%d\n", i);
}
return 0;
}
Output
1
3
5
7
9
Continue statement in C
questions and answers