The Goto Statement

So far we have discussed the flow of executions on specific terms. Like many other languages, the C program unconditionally supports goto statements from one point to another in the branch. Although it may not be necessary to use the goto statement in a highly structured language such as C, there may be occasions when goto is preferred.

Goto needs a label to indicate where the branch should be made. A label should follow any valid variable name and of course a colon. The control must be moved to where the label is placed before the statement is made. The following is a list of common forms of Goto and label statements:

Forward jump
Backward jump

The label: can be anywhere in the program either before or after the goto label: statement. During the running of a program when a statement like

goto outer;

is met, the flow of control will jump to the statement immediately following the label outer: This happens unconditionally.

Note that a goto performs the normal sequential application of the program. If Label: The statement is before the goto label; A loop will be formed and some statements will be executed repeatedly. This national jump is known as the rear jump. On the other hand, if the label: goto is placed after the label; Some statements will be omitted and the jump is known as the forward jump.

Sample Program

#include <stdio.h>

int main() {
  int a=12345,rem,s=0;
     goto outer;
   printf("Reverse : %d",s);
  return 0;