Saturday, 8 May 2021

The goto statement in C with example program

A goto statement has two uses

1. A goto statement can transfer the control to any place in a program; it is useful to provide branching within the loop

2. A goto statement is used to exit from deeply nested loops when an error occur.


  1. The goto statement is used to jump from one line to another line in the program.
  2. Using goto statement we can jump from to to bottom or bottom to top.
  3. To jump from one line to another line, the goto statement requires a label.
  4. Label is a name given to the instruction or line in the program.
  5. When we use a goto statement in the program, the execution control directly jumps to the line with the specified label.
void main(){
   clrscr() ;
   printf("We are at first printf statement!!!\n") ;
   goto last ;
   printf("We are at second printf statement!!!\n") ;
   printf("We are at third printf statement!!!\n") ;
   last: printf("We are at last printf statement!!!\n") ;
   getch() ;


Post a Comment

Note: only a member of this blog may post a comment.

Find Us On Facebook

Computer Basics


C Programming


Java Tutorial


Data Structures


MS Office


Database Management