I am trying to figure out what happens when we use continue statement in code. I have written two code to see the difference but both gives same output
consider this situation with continue statement
Code:
#include <stdio.h>
int main()
{
int x;
for ( x = 0; x < 10; x++ )
if ( x == 4)
{
continue;
printf("x = %d \n", x);
}
else
{
printf(" x = %d \n", x);
}
return 0;
}
x = 0
x = 1
x = 2
x = 3
x = 5
x = 6
x = 7
x = 8
x = 9
without continue statement
Code:
#include <stdio.h>
int main()
{
int x;
for ( x = 0; x < 10; x++ )
if ( x == 4)
{
// continue;
printf("x = %d \n", x);
}
else
{
printf(" x = %d \n", x);
}
return 0;
}
x = 0
x = 1
x = 2
x = 3
x = 4
x = 5
x = 6
x = 7
x = 8
x = 9