continue Statement in while Loop in C
Notes:
continue Statement in while Loop in C programming Language:
continue statement: It continues the loop
Computer skips statement(s) under the continue statement, and transfers the control
to the condition part of the loop in the context of while and do while loops
whereas in the context of for loop, control is transferred to increment / decrement part.
Ex:
- Displaying 1,2,3,4,5 using while loop
int i =1;
while(i<6)
{
printf("%d\n", i);
i++;
}
Ex: continue inside while loop in C
- Displaying 1,2,4,5 using while loop
int i =0;
while(i<5)
{
i++;
if(i==3)
{
continue;
}
printf("%d\n", i);
}
Ex: continue inside do while loop in C
- Displaying 1,2,4,5 using do while loop
int i =0;
do
{
i++;
if(i==3)
{
continue;
}
printf("%d\n", i);
}while(i<5);