0
34kviews
Difference between break and continue along with example.

Mumbai University> FE > Sem 2> STRUCTURED PROGRAMMING APPROACH

Marks: 4M

Year: May 2016, Dec-16

2 Answers
1
4.8kviews
Break Continue
When break is encountered the switch or loop execution is immediately stopped. When continue is encountered, the statements after it are skipped and the loop control jump to next iteration.
break statement is used in switch and loops. continue statement is used in loops only.
Flowchart: enter image description here Flowchart: enter image description here

Create a free account to keep reading this post.

and 3 others joined a min ago.

0
2.3kviews

Break: Example:

#include<stdio.h>
main()
{
    int i;
    for(i=0;i<5;++i)
   {
         if(i==3)
         break;
         printf(“%d “,i);
     }

}

Output:
0 1 2

Continue Example:

#include<stdio.h>
main()
{
    int i;
    for(i=0;i<5;++i)
    {
          if(i==3)
          continue;
          printf(“%d “,i);
      }

}

Output:
0 1 2 4

Create a free account to keep reading this post.

and 2 others joined a min ago.

Please log in to add an answer.