Ads 468x60px

Wednesday 9 January 2013

goto

This function is used to deviate the normal program function, it transfers the control to some other part of program.

Syntaxt
goto label;
with this we can go to the level, but we need to create the label also the syntax of creating a label is
label_name:

Example
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
goto a;
b:
cout<<"to ";
goto c;

c:
cout<<"Absolutestuffs";
goto d;

a:
cout<<"Welcome ";
goto b;

d:
cout<<".com";

getch();
}

Explanation of the program
The control comes inside main and finds the function goto, it sends control to the label a and in label a from the output function the message is printed to the screen.
Now the control finds the function goto again and it sends the control to the next label b and so on.
Output of the above program
Share if you liked this Post using your favorite sharing service:

Subscribe Updates, Its FREE!

0 comments:

Post a Comment

 
Related Posts Plugin for WordPress, Blogger...