The continue statement is for skipping the iteration but it doesn’t work as I expect. Here is my code:
int i = 0;
do
{
if(i== 10)continue;
printf("\n This is = %d",i);
i++;
} while (i<20);
My understanding is that it will skip just
This is = 10
and rest it will print but it is skipping since
This is = 9 till 19
And here is the output
This is = 0
This is = 1
This is = 2
This is = 3
This is = 4
This is = 5
This is = 6
This is = 7
This is = 8
why?
Also when I added for loop ahead of this loop that is entirely getting ignored and not getting executed?
int i = 0;
do
{
if(i== 10)continue;
printf("\n This is = %d",i);
i++;
} while (i<20);
for(int a = 0 ; a<20 ; a++)
{
if(a==10)continue;
printf("\nHere = %d",a);
}
Output :
This is = 0
This is = 1
This is = 2
This is = 3
This is = 4
This is = 5
This is = 6
This is = 7
This is = 8
Why? Please explain.