Pages

Friday, 17 July 2020

Difference and similarity between continue and break | C Language

Write down one similarity and one dissimilarity between break and continue statements.


Similarity


The main difference between break and continue statements in C language is that a break origins the innermost enclosing loop or switch to be exited immediately. Whereas, the continue statement origins the next iteration of the enclosing for, while, or do loop to begin. The continue statement in while and do loops takes the control to the loop's test-condition immediately, whereas in the for loop it takes the control to the increment step of the loop.



Dissimilarity

  • Both continue and break used inside of a loop.
  • Both should be placed inside of any condition otherwise iteration will effect. i.e. if break is sued then the loop will stop immediately and if continue is used without condition then there may cause  infinite loop.

No comments:

Post a Comment