Table of Contents
show
Goto statement is used to branch unconditionally from one point to another within a function and unstructured way of transferring the program control form one point to another within a function.
Syntax
goto label;
goto statement is used in conjunction with an identifier labelled statement. Within the body of the function, in which goto statement is present, an identifier labelled statement with a label name, same as label name used in the goto statement should be present
Forward jump and backward jump,

There can be two or more got statements corresponding to an identifier labelled statements but there cannot be two or more identifier-labeled statement corresponding to 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;
}
}
addition:
printf("%d", sum);
return 0;
}
Output
15
Views: 1