You are on page 1of 7

BREAK STATEMENT IN SWITCH CASE OR LOOP

INTRODUCTION TO BREAK STATEMENT IN C

• Break Statement in C is a loop control statement that is used to


terminate the loop. There are two usages and the given
statement is explained below.

• Inside a Loop: If the break statement is using inside a loop


along with the if statement then if the condition becomes true
the loop is immediately terminated and the next statement after
the loop starts executing by the program control.
• Inside a Switch Case: If Break Statement in C is 
using inside a switch case after each switch case then the break
statement terminates a case after executing the case.

• In general the break statements we used in the situations where we


need to stop the loop execution based on the condition or not sure
how many times the loop is to be iterate. If the break statements 
using inside the nested loop, then the break statement breaks the inner
loop and starts executing the statement after the inner loop of the
program control continue to the outer loop.
SYNTAX OF THE BREAK STATEMENT:

FLOWCHART:
BREAK STATEMENT IN A LOOP
• #include<stdio.h> Output:

int main()
• {
•     printf("Hello World\n");
•     int i, age;
•     for (i=0; i<10; i++){
•         printf("%d\nEnter your age\n", i);
•         scanf("%d", &age);
•         if (age>10)
•         {
•             break;
•         }
•     }
• }
BREAK IN SWITCH-CASE
output:
• #include<stdio.h>

int main()
• {
•     int age;
•     printf("Enter your age\n");
•     scanf("%d", &age);

    switch (age)        
•     {
•     case 3:
•     printf("The age is 3");
•     break;

    case 13:
•     printf("The age is 13");
•     break;

    default:
•     printf("Age is not 3, 13");
•         break;
•     }

    return 0;
THANK
YOU

You might also like