Computer Science, asked by bikeashhd, 20 hours ago

cprogramming
break statement​

Answers

Answered by nasirxoz
0

Answer:

its used to break a function i means to stop a function

Answered by MrTSR
2

Break Statement

Break statement is used to terminate the loop in C. A break statement can be used with any type of looping structure.

Break statement  within a loop

  • If break  statement  encountered  within a loop,  then the loop  is terminated  and the  control flow is  passed to the  statements in  the next loop.

Break statement  within nested  loop

  • A break  statement  inside the  inner loop  causes the  program to  exit from the  inner loop.  The program  control is then  passed to the  outside loop.

Break statement  outside outer  loop

  • The program  exits, if the  break  statement is  encountered  and the  control is  passed to the  next loop.

Example – Break Statement

#include <stdio.h>

int main()

{

         int num1 =0;

        while(num1<=50)

        {

               printf("variable value is:  

%d", num1);

               if (num1==2)

               {

                  break;

               }

               num1++;

     }

     printf("Out of while-loop");

     return 0;

}

OUTPUT

variable value is: 0

variable value is: 1

variable value is: 2

variable value is: 2

Out of while-loop

Similar questions