This statement is a unconditional jump statement. It can be used anywhere in the program to jump from its current execution to some other lines in the code. Once it is jumped to some other line, it will continue executing the codes from there sequentially. It cannot come back again to previous execution lines. In order to refer to the line it has to jump, we label the line.
Syntax:
goto label; ............. ............. ............. label: statement;
Example:
//Write a C Program Which Print 1 To 10 Number Using goto statement. #include<stdio.h> #include<conio.h> void main() { int i=1; clrscr(); count: //This is Label printf("%d\n",i); i++; if(i<=10) { goto count; //This jumps to label "count:" } getch(); }
break Statement
continue Statement
No comments:
Post a Comment