Jump Statements in C

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

What are Jump Statements in C?

Jump statements are control flow statements that allow you to modify the order in which programs execute. These statements give the programmer flexibility and control over the program's logic.

Types of Jump Statements in C

There are four types of jump statements in the C language:

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

Break Statement in C

The Break statement stops the execution of a loop or switch. It transfers program control to the next sentence, which is immediately following the loop or switch.

Where to Use Break Statements in C?

In C, the break statement can be used for the following:

  • To get out of the loop.
  • Come out of the nested loops.
  • To get out of the switch case.

How does the break statement work?

  • The loop execution begins when the test condition has been evaluated.
  • If the break condition exists, it will be assessed.
  • If the condition is true, the program control moves to the break statement and avoids the loop's subsequent execution by jumping to the statements just below it.
  • If the condition is false, the program control flow proceeds as normal.

Continue Statement in C

The Continue statement skips the current iteration of the loop and transfers program control to the next iteration of it. Unlike the break statement, it does not terminate the loop execution.

Working of the Continue Statement

  • The loop's execution begins once the loop condition is determined to be true.
  • The status of the continue statement will be evaluated.
  • If the condition is false, normal execution will continue.
  • If the condition is met, the program control will return to the beginning of the loop and all statements following the continue will be skipped.
  • The steps will be repeated till the loop ends.

Goto Statement in C

A goto statement transfers program control to a labeled statement inside its scope. This function is used to exit a loop or nested loop and return to the outer loop.​ Makes program logic complex and difficult to understand.

Disadvantages of Using the Goto Statement

  • The goto statement is strongly discouraged since it complicates program logic.
  • The usage of goto makes tracing the flow of the program extremely difficult.
  • The usage of goto makes analyzing and verifying the correctness of programs (especially those including loops) extremely difficult.
  • The need for goto can be avoided entirely by utilizing break and continue statements.

Return Statement in C

When a function is completed, the return statement in C is used to provide the caller with a value. It is commonly used to return a value to the caller code.

Self-paced Membership
  • 22+ Video Courses
  • 800+ Hands-On Labs
  • 400+ Quick Notes
  • 55+ Skill Tests
  • 45+ 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.
Accept cookies & close this