Goto Statement in c

Goto statement is used for control transfer.where control transfer is meant for looping (repeating a set of statements).this looping may become infinite if you do not control it with a condition.goto is the control transfer statement in clangauge .

syntax:

Goto label; …. ….. …….. ……………… Label; Statement;

Goto label;
…. ….. ……..
………………
Label;
Statement;

here , the label is an identifier. when there is goto statement then the controller skips all in the middle and jumps to the label.the label should be en with a semi-colon(;).no two statements should have same label.

a goto statement breaks the normal sequencial execution of a program.if the lable comes before the goto statement ,a loop will be formed .to aviod memory buffer over flow ,we should goto inside if condition

flowchart:

goto in c

example:-

#include<math.h>
main()
{
int k;
k=1;
number:
if(k<=22)
{
printf("%d \n",k);
k=k+1;
goto number;
}
}

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22