Break and Continue Statement in C

Hi all, I expectation till now you should be dazzled with the intensity of circles in C programming. Well, today I will inform you concerning the two watchwords which are utilized habitually inside circles.

These two watchwords are given underneath.

break

proceed

Let’s find out about them individually.

Break Statement in C

It is the catchphrase which is commonly used to break the execution of the circle. Once in awhile, we need to end the circle subsequent to getting the ideal outcomes. In those conditions, break watchword fills our need. In the wake of experiencing the break catchphrase, control of program movements to the following proclamation after the circle. They are utilized every now and again in the odd circles.

Let’s take one model for better clarification.

#include<stdio.h>
 
void main()
{
 int i;
 
 for(i=0;i<5;i++)
 {
  printf("%d",i);
  break;
  printf("This will not appear!");
 }
 
 printf("nOnly this will appear!");
}

OUTPUT

0
Only this will apperar!

Clarification

In the above program, I have begun a circle. Inside the body of the circle I have composed barely any announcements. Most importantly the printf() work is executed which will show the main circle counter worth.

After that, I have composed break catchphrase. What’s more, soon after that I have composed another printf() work.

Be that as it may, during the execution of program compiler won’t execute the second printf() work underneath break catchphrase. As I said before it will assume the responsibility for the program outside the circle.

Furthermore, in the last, I have another printf() work which is outside the circle. This is executed in light of the fact that it lies outside the circle.

Proceed with Statement in C

It is a partner of break catchphrase. At some point, while composing complex program we need a watchword which will take the control to the start. Proceed with watchword fills this need and it is utilized with a circle. So at whatever point compiler experiences the proceed with watchword it takes the control to the beginning of circle.

A program for proceeding with watchword is given underneath.

Clarification

I have recently supplanted the break watchword with the proceeding. Furthermore, it has an enormous effect on the program.

Execution of the program is like the prior one. But one thing that this time the circle will be executed completely. Be that as it may, it won’t execute the printf() work after proceeding with a watchword.

Since after the proceed with watchword the control moves to the start. So it will never reach to that capacity.

Toward the finish of the circle, last printf() capacity will get executed.

Attempt This

You can give your hands a shot these two watchwords by making basic projects.

Compose a program to check a prime number which is entered by the client.

Compose a program to check composite number which is entered by the client.

Leave a Comment

error: Alert: Content is protected!!