Jump statements are control flow statements that allow you to modify the sequence in which programs run. These statements give the programmer flexibility and control over the program's logic.
In the C++ language, jump statements are classified into four types:
The Break statement terminates the execution of a loop or switch. It moves program control to the next sentence after the loop or switch.
There are two ways to use break statements in C++:
The continue statement skips the current iteration of a loop and returns control to the start of the iteration. The statements following the continue statement are skipped, and the iteration restarts.
The continue statement in a for loop moves control to the update expression and skips the current iteration.
The continue statement in a while loop returns control to the while condition and skips the current iteration.
When a continue statement appears in the do...while loop, the control jumps immediately to the update expression, skipping the remaining code in the loop body.
When used with nested loops in C++, the continue statement skips the inner loop's current iteration.
It is a control flow method that allows programmers to direct the execution of a program to a specific labeled statement inside the code. The goto command in C++ allows you to skip the code's normal sequential flow and go to a specific position within it.
When a function finishes running, the C++ return statement is used to return a value to the caller. It is commonly used to return a value to the caller code.