0
what is the use of continue
2 Antworten
+ 1
It lets you jump an iteration in a loop. Let's say you have a for loop from 0 to 10. And you write in the code an if condition for i==5, and you write continue right after that. This means that when the loop reaches that 5, and as soon as it sees the condition, it will skip the remaining part of code in the loop.
The easiest example to test this is if you write a for loop, and then make a check if i % 2 == 0, and if that is true, write continue. And below the if statement (outside its scope), let the program print the current i. This will show you only the odd numbers.
0
thanks man