I want clarification on the continue
statement.
#include <stdio.h>
int main (void) {
int i;
while (i < 10) {
if (i == 4) {
i++;
continue;
}
printf("%d\n", i);
i++;
}
return 0;
}
This code outputs 0-9, skipping the number 4. I removed the increment statement below if
statement:
while (i < 10) {
if (i == 4) {
continue;
}
printf("%d\n", i);
i++;
I read continue
will break one iteration of the loop. I assumed it will continue to the printf
statement, move on and still output 0-9, skipping 4.
It is stuck in a loop and only printed 0, 1, 2 & 3.