#include <stdio.h>
int main ()
{
int n;
for (n=100;n<=200;n++)
{
if (n%3==0)
continue;
printf ("%d", n);
}
printf ("\ n");
return 0;
}
The number of outputs from 100 to 200 that cannot be divisible by 3
#include <stdio.h>
int main ()
{
int n;
for (n=100;n<=200;n++)
{
while (n%3==0) {
continue;}
printf ("%d", n);
}
printf ("\ n");
return 0;
} Outputs 100 to 200 cannot be divisible by 3 number of the
first program seventh line with the IF statement the second program seventh line with a while statement with the
first program can output 100 to 200 of all the number can not be divisible by 3 But with the second one can only output 100 101 then no, why.
Continue is only responsible for having a loop statement produce a "jump back", which is the innermost loop statement closest to continue.
Your first continue is for (n=100;n<=200;n++) (because if is not a loop statement, continue will not find it)
Your second continue is the while (n%3==0) loop, because this is the closest inner loop to the continue.
1 2 |
while (n%3==0) {continue;}//When n=102, this while will loop indefinitely, freezing |