It will only print 1, 2 and 3. The continue keyword helps to skip the current iteration of the loop. Refer the below example program. According to the above program, the loop iterates from 1 to 5. So, the condition becomes true. Therefore, the continue statement executes and the iteration skips to the next. Reminder after dividing 2 by 2 is 0. The break statement is primarily used as the exit statement, which helps in escaping from the current block or loop. Conversely, the continue statement helps in jumping from the current loop iteration to the next loop.
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. Causes It causes early termination of loop. It causes early execution of the next iteration.
Continuation 'break' stops the continuation of loop. Other uses 'break' can be used with 'switch', 'label'. First, use to terminate the execution of case in a switch. It does not affect the loop enclosing the switch. Below I have shared difference between break and continue statements along with an example in C. If you have any doubts related to above difference between break and continue tutorial then feel free to ask it by commenting below.
Can you share your e mail address or something so that we can discuss about it? Popular Tutorials Data Types in C. C for Loop. Arrays in C Programming. Pointers in C. Find roots of a quadratic equation. Print Pyramids and Patterns. Check prime number. Print the Fibonacci series. Reference Materials string. Start Learning C.
0コメント