#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
i=1;
up:printf("\n Hello");
if(i<5)
{
i++;
goto up;
}
getch();
}
------------------------------------------------------------------
Syntax statement:
labeled-statement
jump-statementjump-statement:
goto identifier ;labeled-statement:
identifier : statement
A statement label is meaningful only to a goto statement; in any other context, a labeled statement is executed without regard to the label.
A jump-statement must reside in the same function and can appear before only one statement in the same function. The set of identifier names following a goto has its own name space so the names do not interfere with other identifiers. Labels cannot be redeclared. See Name Spaces for more information.
It is good programming style to use the break, continue, and return statement in preference to goto whenever possible. Since the break statement only exits from one level of the loop, agoto may be necessary for exiting a loop from within a deeply nested loop.
No comments:
Post a Comment