14
Reply

What happens when you encounter a continue statement inside the for loop?

balaji jadav

balaji jadav

10y
3.8k
0
Reply

    Dear If you use continue in for loop it will skip the that value , If you use break it will not give any output for that ...for(var i=0;i<=10;i++) { if(i==5) continue; if(i==6) break; console.writeline(i); }//For Continue output : 1234678910 //For break output : 1234

    It will skip all the statements after the continue statement and go for the next iteration.

    it will skip the execution of the current statements and moves to the loop for next iteration

    From the continue statement all the lines of code won't get executed for that specific iteration. Loop continuing to next iteration.for(i=1;i<=10;i++) { //My All lines of code executes for all iteration if(i==5) continue; //Below line of code wont executed when i==5 print(i); }for more details https://msdn.microsoft.com/en-us/library/923ahwt1.aspx

    skipping the value and continues the loop.

    It will skip all the statements after the continue statement and go for the next iteration.

    The loop does not execute the specific value

    If you use the continue statement in any loop then it will skip the implementation of remaining step and execution of program jump to the starting of loop.......

    for(i=1;i<=10;i++) { if(i==5)continue; print(i); }O/P 1234678910

    it will skip one number and continue form another number... for example: in for loop we are printing 1 to 10 numbers and in that case if we are printing 5 number the we written in if statement that (if I==5) then we write continue statement, then in output it will print 1 to 4 and it will skip 5 and then continue to print 6 to 10.

    it will skip one number and continue form another number... for example: in for loop we are printing 1 to 10 numbers and in that case if we are printing 5 number the we written in if statement that (if I==5) then we write continue statement, then in output it will print 1 to 4 and it will skip 5 and then continue to print 6 to 10.

    It skips the rest of the current iteration and start the next iteration execution.

    Basically 'Continue' is a branching statement means when is found in a code,compiler understand to continue the same thing that's why the rest part of code is not executed and loop continuous works until condition satisfied.

    The code for the rest of the loop is ignored, the control is transferred back to the beginning of the loop.