- 1
What's the difference between writing "continue" and not writing anything?
5 Réponses
+ 2
with "continue" you stop current loop iteration and go to the start of the loop
0
Writing Continue is similar to Break. Notice how Break stops a loop, and then goes onto what is next in the code? Continue breaks a loop and starts outputting the code from the start with the changes already implemented, such as a+= 1 gone through twice, and then the continue breaks the possibility of the loop being repeated again. Not writing anything, the loop would just continue on for "Infinity" in a happy little Theoretical World, but through Experiment it ends through either the system crashing, the loop being broken by the program being closed, or similar.
0
for example
i =5;
while(i!=0)
{
i--;
print"Hello";
}
This program will print the word until value of becomes 0.
same program with continue
i =5;
while(i!=0)
{
i--;
continue;
print"Hello";
}
this program will check whether i!=0 ,if true it will decrement i by 1 and then go to the condition in while loop without printing Hello
0
while loop run till condition is satisfy
if we want the program to be continuously so we use continue to start the program from starting .
I hope u would understand it
0
If you use continue anything after continue inside the loop will not be executed and the loop will simply go to the next iteration. The absence of continue just imply 's that that for every iteration everything under the loop will be executed. Hope this helps:)