Goto Statement in C Programming

It is a well known as ‘jumping statement in c.’ It is primarily used to transfer the control of execution to any place in a program. It is useful to provide branching within a loop.

When the loops are deeply nested at that if an error occurs then it is difficult to get exited from such loops. Simple break statement cannot work here properly. In this situations, goto statement is used.

Syntax :

	goto [expr];

Figure :

Program :

/*  Program to demonstrate goto statement.
Creation Date : 09 Nov 2010 08:14:00 PM
Author : [Technowell, Sangli] */

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

int main(void)
	int i=1, j;
		for(j=1; j<=3; j++)
			printf(" * ");
			goto stop;
		i = i + 1;
		printf("\n\n Exited !");
	return 0;

Output :

 *  *


Leave A Comment

Your email address will not be published. Required fields are marked *