Saturday, March 6, 2010

Continue Statement

The remaining loop statements after continue statement are skipped and the computation proceeds directly to the next pass through the loop.

consider this eg:


int main()
{
int i;
for(i=0;i < 2;i++)
{
printf("Before continue statement");
continue;
printf("After continue statement");
}
return 0;
}

Output


Before continue statement
Before continue statement


Logic


In this program,compiler show one warning "Unreachable Code".
all statement which are after continue statement will be skipped.
so printf("After continue statement"); is unreachable code(This statement will not be execute ).
so the operation will be like this,



0 comments:

Post a Comment