A goto statement in C language is an unconditional jump. This statement uses ‘label’ to jump to the labeled statement in the program. Here ‘label can be any identifier except keywords’. This statement is used to perform unconditional jump to the labeled statement within the function.
Syntax for goto statement in C
goto label;
...
..
.
label:
statements;
Here ‘label can be any identifier except keywords’.
program of goto statement in C
//An example of goto statement in C
#include<stdio.h>
int main()
{
int x =1;
start:
printf("%d\n",x);
x++;
if(x < 5)
{
goto start;
}
return 0;
}
output
1
2
3
4