• C-language provides goto statement to transfer control unconditionally to other part of the program.
  • Although use of goto statement is not advisable but sometime it is desirable to use go to statement.
  • It has the following form:

goto Statement

  • goto statement requires a label to determine where to transfer the control.
  • A label must end with colon (:)
  • We can use any valid name as a label similar to variable name.
  • When compiler encounters goto statement with a label name then, it transfers the control to the location where label has been defined in the program.
  • When we use goto statement either some statement are execute repeatedly or skipped.
  • When goto statement is placed after the label, control jumps backward direction and some statement are repeated. Such type of go to jump is called backward jump.
  • When goto statement is placed before the label in the program, control transfers to the label and some statements are skipped. Such type of jump is called forward jump.
  • In highly structure programming language such as c, it is not advisable to use go to statement.
  • We should avoid using go to statement as far as possible because it affects performance of the program.
  • the following program demonstrates the use of goto statement.
/* C program to calculate sum using goto statement.
#include "stdio.h"
#include "conio.h"

void main()
   float x,y,sum;
       printf("\n Enter X and Y : ");
       scanf("%f %f", &x, &y) ;
   if( x <=0 || y <= 0)
        goto input ;
   sum = x + y ;
   printf("\n Answer is %.2f", sum);