0
33kviews
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
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
Please log in to add an answer.