C'Laguage - [GOTO Statement]

♠ Posted by Unknown in at 23:56

GOTO STATEMENT.

C supports the goto statement to branch unconditionally from one point to another in the program.  Although if may not be essentially to use the goto statement in a highly structured language like C. 

The goto requires 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 colon.  The label is placed immediately before the statement where the control is to be transferred.  The general form of goto and lbel statements are shown below.

Image: goto Statement

The label: can be any where in the program either before or after the goto label; statement.  If the label: is before the statement goto label; a loop will be formed and some statement will be executed repeatedly.  Such a jump is known as a backward jump.  

On the other hand, If the label: is placed after the goto label; some statements will be skipped and the jump is known as a forward jump.