Jump statements


Jump statements


In programming languages, a command written by the programmer for the computer to act is called a statement. Statements are like instructions that are given to a computer.

Jump statements are used in programming languages to jump to a specific line of code, breaking the normal flow of code.


Types of Jump Statements


Flow control: The order in which the code is executed.


Break:

Break statement is used to break or stop the flow of control. It is used in loops to break flow control. A break statement is used in a loop in such a way that when a particular condition becomes true, the break statement is executed and we come out of the loop immediately at that moment.


Code


Break statement example

Output


Output of break statement

Continue:

Continue statement is used to skip an iteration when a condition is true. It is very similar to break, break terminates the entire loop while continue skips that iteration and goes on to the next iteration.


Code


Continue statement example

Output


Output of continue statement

Pass:

Pass statement is used as a placeholder. When the pass statement is executed, nothing happens. This can be used when we want to write a piece of code in the future but cannot leave the space empty.


Code


Pass statement example

Return:

Return statement is used in functions to terminate the function and return a value to the calling function.


Return statement example