+ 1

Difference between break and continue?

4 points ....

6th Aug 2018, 2:45 AM
Kathapriya Giri
Kathapriya Giri - avatar
3 Respuestas
+ 3
for(...) { // instructions ... <---+ if(some_condition) | continue; -------------+ if(some_condition) break; ------------------+ } | // instructions <-----------+ continue means to go back and execute the first instruction within loop body. break means to break out (jump out of) the loop body and execute next instruction following the loop body (if there was any) Hth, cmiiw
6th Aug 2018, 4:01 AM
Ipang
+ 2
break will exit the loop. continue skips the remaining code in the current iteration of the loop then continues looping
6th Aug 2018, 3:42 AM
Jordan Chapman
Jordan Chapman - avatar
+ 1
Break leaves the loop completely and executes the statements after the loop. Whereas Continue leaves the current iteration and executes with the next value in the loop. ... A continue statement is used to end the current loop iteration and return control to the loop statement. BASIS FOR COMPARISON BREAK CONTINUE Task It terminates the execution of remaining iteration of the loop. It terminates only the current iteration of the loop. Control after break/continue 'break' resumes the control of the program to the end of loop enclosing that 'break'. 'continue' resumes the control of the program to the next iteration of that loop enclosing 'continue'. Causes It causes early termination of loop. It causes early execution of the next iteration. Continuation 'break' stops the continuation of loop. 'continue' do not stops the continuation of loop, it only stops the current iteration. Other uses 'break' can be used with 'switch', 'label'. 'continue' can not be executed with 'switch' and 'labels'.
11th Aug 2018, 10:27 AM
deepak sharma
deepak sharma - avatar