Goto Statement

When a goto statement is encountered in a C program, the control jumps directly to the label mentioned in the goto statement

Syntax

goto label_name;
..
..
label_name: C-statements

FLOW DIAGRAM

goto Statement

Example

#include <stdio.h>
int main()
{
 int sum=0;  
 for(int i = 0; i<=10; i++)
  {
    sum = sum+i; 
    if(i==5){ 
    goto addition;
  }
 printf("%d", sum);
 return 0;
}

Output

 

15