C++ Jump Statements
Jumping statement unconditionally transfer program control within a function. C++ language provides us multiple statements through which we can transfer the control anywhere in the program.
There are jump statement is as follows:
In Computer Programming, The break statement terminates the loop immediately when it is encountered, simply comes out of the loop. Immediate after the closing brace of theloop will be executed.
The Syntax of the Break statement is as follows:
ii. Continue Statement
The continue statement skips some statements inside the loop. Loop will be restarted when continue is encountered.
The Syntax of the continue statement is as follows:
iii. Return Statement
C++ The return keyword returns a value after completing its assigned task. Only stored in the variable is passed to the function.
iv. 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:
Here Label can be any pain text except the C++ keyword and it can be set anywhere in the C++ program above.