Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, March 10, 2015

What is break statement ?

Break is also called jumping statement. It is used to exit or terminating from the loop.
It is also used in switch(). When a break statement is encountered inside the loop, the loop is immediately exited and the program continues with the statement immediately following the loop.

When the loops are nested, the break would only exit from the loop containing it. The break will exit only a single loop
Syntax:
while(…)
{
      -----------
      if(condition)
            break;   // exit from the loop;
      -----------
      ------------
}


Ex:

      #include<stdio.h>
      #include<conio.h>
      void main()
      {
            int i;
            for(i=0;i<=10;i++)
            {
                  if(i==6)
                       break;
                  else
                        printf(“%d\n”,i);
            }
            getch();
      }

Output:
            1
            2
            3
            4
            5
     


No comments:

Post a Comment