Published on: 12th Nov 2010 | Last Updated on: 24th Nov 2011
Goto Statement :
It is a well known as 'jumping statement.' 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 : www.technoexam.com [Technowell, Sangli] */
#include <stdio.h> #include <conio.h> void main() { int i=1, j; clrscr(); while(i<=3) { for(j=1; j<=3; j++) { printf(" * "); if(j==2) goto stop; } i = i + 1; } stop: printf("\n\n Exited !"); getch(); }
Output :
* * Exited_
Link this post on your Blog/Website :

