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.
- The goto statement is used to jump from one line to another line in the program.
- Using goto statement we can jump from to to bottom or bottom to top.
- To jump from one line to another line, the goto statement requires a label.
- Label is a name given to the instruction or line in the program.
- 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.