Goto Example C Language
Goto is a statement which is used to transfer execution
control to a label. Goto is an old approach of programming which unstructured a
program structure. So programmer ignor goto in modern programming.
In some old programming language like Assembly, goto is used
to implement iteration.
Syntax :
Example :
Write a program to print numbers 1 to 10 using goto.
#include<stdio.h>
#include<conio.h>
/*##########################
Girfa Student Help
goto example
##########################*/
void main()
{
int n;
clrscr();
n=1;
incr:
printf("\t%d",n);
n++;
if(n<=10)
goto incr;
getch();
}
No comments:
Post a Comment