UNCONDITIONAL CONTROL STATEMENTS


BREAK
It is used to terminate a switch statement.
BREAK is a keyword that allows us to jump out of a loop instantly, without waiting to get back to the conditional test.
CONTINUE
The keywords continue allow us to take the control to the beginning of the loop, by passing the statements inside the loop which have not yet been executed.
GOTO STATEMENT
ā€˜cā€™ supports go to statement to branch unconditionally from one point to another in the program.
The GOTO General Form is

                goto Label;
                -----------               Label:
                ----------                 Statement
                ----------                 -------------
                Label:                    -----------                                 
                Statement;             ------------
                Forward jump        goto Label:
                Backward jump

              

The go to require a "label". In order to identify the place where the branch is to be made. A "label" is any valid variable name, and must be followed by a "colors". The label is placed immediately before the statement where the control is to be transferred. The label can be any where in the program either before (or) after go to label; state.
Ex; program to print ā€˜nā€™ natural number

                main()
                {
                  int n,i=1;
                  clrscr();
                  printf("enternumber");
                  scanf("%d\t",i);
                  printf("natural numbers from 1to%d",n);
                  lb: printf("%d\t",i);
                  i++;
                  if(i<=n)
                  goto lb;
                  getch();
                }
              
Copyright © 2018-2020 TutorialToUs. All rights reserved.