This is the source code from the C Programming Tutorial. In this source code, you are going to learn about Break and continue statement in a C Programming language.
It is sometimes desirable to skip some statements inside the loop or terminate the loop immediately without checking the test expression.
In such cases, we can use break
and continue
statements to skip some part of the program.
break Statement
When we want to terminate the loop (for loop, while loop and do-while loop) break
statement is used. Whenbreak
is encountered inside any loop, control automatically passes to the first statement after the loop.
syntax of break statement
break;
Flowchart of break statement

Source code of break statement
//break statement in c programming
#include
<stdio.h>
#include
<stdlib.h>
#include
<math.h>
int main()
{
int num;
printf("Enter a number \n");
scanf("%d", &num);
while(num <= 10){
if(num == 5){
printf("try to enter new number!!");
break;
}
printf("your entered number is %d \n", num);
num++;
}
}
In C programming, break statement is also used with switch case statement.
continue statement
The continue
statement skips the execution of the statement after it and takes the control through the next cycle of the loop.
syntax of continue statement
continue;
Flowchart of continue statement

Source code of continue statement
//continue statement in c programming
#include
<stdio.h>
#include
<stdlib.h>
#include
<math.h>
int main()
{
in i, j;
for(i = 1; i<=2; i++){
for
(j = 1; j<=2; j++){
if(i == j)
continue;
printf("%d %d \n", i, j);
}
}
return
0;
}