Jump Statements in C++

Level : Beginner
Mentor: Shailendra Chauhan
Duration : 00:02:00

What are Jump Statements in C++?

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.

Types of Jump Statements C++

In the C++ language, jump statements are classified into four types:

  1. Break
  2. Continue
  3. Goto
  4. Return

Break Statement in C++

The Break statement terminates the execution of a loop or switch.​ It moves program control to the next sentence after the loop or switch.

Where can you use break statements in C++?

There are two ways to use break statements in C++:

  1. Break statement in the switch case: The break statement is used within a switch statement to stop the execution of the switch statement and exit the block of code. When a break statement appears within a switch block, the control flow is shifted to the end of the switch block, and the remaining case statements are skipped.
  2. Break statement in a loop: The break statement in C++ is used within loops to terminate the loop's execution when a certain condition is satisfied. It passes control to the statement that comes after the loop. 

Continue Statement 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.

Continue Statement with for loop in C++

The continue statement in a for loop moves control to the update expression and skips the current iteration.

Continue Statement with while loop in C++

The continue statement in a while loop returns control to the while condition and skips the current iteration.

Continue Statement with do...while loop in C++

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.

Continue Statement with a Nested Loop in C++

When used with nested loops in C++, the continue statement skips the inner loop's current iteration.

Goto Statement in C++

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.

Return statement in C++

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.

Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this