C - break Statement

<<Previous

Next >>





The break statement is used to branch out the switch case statement. It is also used to terminate the execution of loop statements such as for,while and do...while.

Syntax
  break;

For example, consider a nested while-loop

while(expression)
{
	while(expression)
	{
		if (expression)
		break;
		statements
	}
	statements
}

Here the break will terminate the inner while-loop and proceed to execute the statements of the outer while-loop. Following is an example C-program using break statement

#include<stdio.h>


int main()
{
  int a = 0;

  while(a <= 5)
  {
    if(a ==3)
     break;
    printf("The value of a = %d\n",a);
    a++ ;
  }

  printf("The final value of a = %d\n",a);

  return(0);

}

When you compile and execute the above program, you will get the following result.




<< Previous

Next >>







C - break Statement

<<Previous

Next >>





The break statement is used to branch out the switch case statement. It is also used to terminate the execution of loop statements such as for,while and do...while.

Syntax
  break;

For example, consider a nested while-loop

while(expression)
{
	while(expression)
	{
		if (expression)
		break;
		statements
	}
	statements
}

Here the break will terminate the inner while-loop and proceed to execute the statements of the outer while-loop. Following is an example C-program using break statement

#include<stdio.h>


int main()
{
  int a = 0;

  while(a <= 5)
  {
    if(a ==3)
     break;
    printf("The value of a = %d\n",a);
    a++ ;
  }

  printf("The final value of a = %d\n",a);

  return(0);

}

When you compile and execute the above program, you will get the following result.




<< Previous

Next >>







Learn about Hashing and Hash table

Learn Expression Tree

OS Kernel Architecture

OS Arcitecture of Windows, Linux and MacOS

Learn OS scheduling Algorithms