Goto Statement in C by R4R Team

Goto:

-This statement are used to jump from one line to another line in the program.
-It is the jumping statement in C.

Syntax-
xyz:
goto xyx;


-when the execution of program are come at the goto line then it will jump to the xyz: line.
-Goto statement are also be used to make a loops.
-Goto statement are also goes in infinite loop.

program-

#include < stdio.h>
int main()
{
int i=0;
point:
printf("i=%d\n",i);
i++;
if(i< 4)
goto point;
}


output-

i=0
i=1
i=2
i=3

-In this program, we start with i=0 and print value of i and increase the value of i with 1. and go back to the 'point' and repeat this process until if(i< 4) will become false so that goto statement will not execute.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!