C++ GOTO Statement

In C++ , goto statement is used for change the normal sequence of program execution by transferring control to other a part of the program.

The C++ goto statement is additionally referred to as jump statement.

Syntax : -

goto label;

In the syntax above,

label is an identifier.

When goto label; is encountered, the control of program bounces to label: and executes the code beneath it.

goto statement
Goto statement Working

Example : -

#include <iostream>
using namespace std;

int main() {
int i = 10;
int j = 20;
if(i > j)
goto igreater;
goto jgreater;
cout << i <<" is greater";
cout << j <<" is greater";

20 is greater
Use of goto statement is very discouraged because it makes difficult to trace the control flow of a program, making the program hard to know and hard to switch .

Any program that uses a goto are often rewritten in order that it doesn't need the goto.
Reason to Avoid goto Statement

The goto statement gives power to leap to any a part of program but, makes the logic of the program complex.

In modern programming, goto statement is taken into account a harmful and a nasty programming practice.