Goto Statement In CPP

Goto statement is also known as Jump statement. It directly jumps to the specified label.

It is also used to move the control to the other part of the program.

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

void main()
{
clrscr();

cout << "hello" << endl;            
goto a;
cout << "Welcome" << endl;   //this statement will be skipped

a:                // define a label

cout << "thanks for using this program" << endl;

getch();
}

Output:
hello
thanks for using this program

Leave a Reply