Goto Statement in C
This article is about the goto statement in C programming. Also, when and how to use it in your C programs.
Goto statement in C
The goto statement is a transfer control statement that provides an unconditional jump from the ‘goto’ to a specified labeled statement in the same function.
When a goto statement is met, the control of the program is transferred to the label and starts executing the code given in the label. The label is an identifier
NOTE – The main disadvantage of the goto statement is that it makes it difficult to trace the control flow of a program and makes the program hard to understand and modify.
Syntax
goto label;
... .. ...
... .. ...
label:
statement;
Example
[maxbutton id=”1″ url=”https://coderseditor.com/?id=176″ ]
#include <stdio.h>
int main()
{
int a,i=1;
printf("Enter the value:");
scanf("%d",&a);
data:
printf("%d x %d = %d\n",a,i,a*i);
i++;
if(i<=5)
goto data;
}