Goto Statement in C

The goto statement requires a label in order to identity the place where the jump the control.a lable is any valid variable name must be followod by a colon.the label is placed.immediately before the statement where the control is to be transfered.

the following simple syntax of the goto statement.



statement
	goto label:
label;
	'code
							

Example


#include<stdio.h>
#include<conio.h>

void main()
{
	int i;
	clrscr();
	
	i=1;
	while(i<=10)
	{
		printf("%d",i);
		i++;
		if(i==5)
		{
			goto label1;
		}
	}
	label:
		printf("Loop Break in 5");
		
	getch();
}							
							
Share Share on Facebook Share on Twitter Share on Google+ Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit