Harshit Sethi wrote:Yeah thats exactly what i am asking,in for loop it happens even if the rest of the body is skipped but in while loop by executing this program,it seems the same is not true for while loop.
Remember that the for loop has four parts -- the initialization, the condition, the reinitialization, and the body. When a continue occurs, the rest of the body is skipped, the reinitialization is executed, and the condition is check for the next iteration. With a while loop, there is only two parts -- the condition, and the body. The behavior is pretty much the same. The rest of the body is skipped, and the condition is checked for the next iteration.
Obviously, with a while loop, the reinitialization isn't executed, because there is no such a thing.
Joined: Jul 16, 2010
So that means i have to be cautious and don't think that the increment after continue in while loop will be executed .