Interviews3 answers
What happens when you encounter a Continue statement inside the for loop?
3 Answers
it breaks the current iteration and start next iteration. means it doesn't run code after continue and jump to the next iteration.
Anchal SikarwarPosted Aug 7, 2020, 4:39 AM EDT
If you place a continue statement inside a ‘for’ loop, then code execution will move to next iteration by skipping all the lines of code after ‘Continue’ statement.
EX:
for(int i=0; 1<5; i++)
{
if(i==3)
{
continue;
}
Console.WriteLine(i.ToString());
}
Output:
1
2
4
5
Explanation: In third iteration code execution will be skipped once it enters into If condition and donot execute Console.WriteLine(i.ToString());
Surendra BadireddyPosted Aug 6, 2020, 8:48 PM EDT
The continue statement skips the current iteration and moves to next iteration
Varun SetiaPosted Aug 5, 2020, 9:24 PM EDT

