C++goto Statement

C++goto Statement


C++ goto Statement 
  • It is well known as ‘the jumping statement’. It is primarily used to transfer control of execution to any place in a program. It is useful to provide branching within a loop.
  • When the loops are deeply nested that if an error occurs then it is difficult to get excited from such loops. A Simple break statement cannot work here properly. In this situation, a goto statement is used. A goto statement in the C++ programming language provides an unconditional jump from goto a labeled statement in the same function.
The Syntax for goto statement is as follows:
goto label;
..
.
label statement;
Here Label can be any pain text except the C++ keyword and it can be set anywhere in the C++ program above.
Example
  
Output