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() ;
}

0 comments :

Post a Comment

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

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top