Jump Statements in C

Last Updated : 30 Jun, 2026

In C, jump statements are used to jump from one part of the code to another altering the normal flow of the program. They are used to transfer the program control to somewhere else in the program.

Types of Jump Statements in C

C provides the following jump statements:

Break Statement

The break statement is used to immediately terminate a loop or switch statement and transfer control to the next statement after it.

  • Exits the current for, while, or do-while loop when a specified condition is met.
  • Stops the execution of a matched switch case and prevents fall-through to subsequent cases.
Break-Statement-Flow-Diagram

Example

C
#include <stdio.h>
int main()
{
    int i;
    for (i = 1; i <= 10; i++) {

        if (i == 6) {
            break;
        }
        printf("%d ", i);
    }
    printf("Loop exited.\n");
    return 0;
}

Output
1 2 3 4 5 Loop exited.

Explanation

  • Loop Execution Starts and goes normally till i = 5.
  • When i = 6, the condition for the break statement becomes true and the program control immediately exits the loop.
  • The control continues with the remaining statements outside the loop.

Uses of break

The break statement is used in C for the following purposes:

  • To come out of the loop.
  • To come out of the switch case.

Note:The break statement terminates only the innermost loop or switch statement in which it is used. In nested loops, it exits only the inner loop while the outer loop continues executing, and in a switch statement, it prevents execution from falling through to subsequent cases.

Continue Statement

The continue statement is used to skip the remaining statements in the current iteration of a loop and immediately move to the next iteration.

  • Skips the remaining statements of the current iteration when a specified condition is met.
  • Continues loop execution by transferring control directly to the next iteration without terminating the loop.

Note: Just like break, the continue statement also works for one loop at a time.

Flowchart-of-continue-Statement

Example

C
#include <stdio.h>

int main()
{
    int i;
    for (i = 0; i < 5; i++) {
        if (i == 2) {
            printf("Skipping iteration %d\n", i);
            continue;
        }
        printf("Executing iteration %d\n", i);
    }
    return 0;
}

Output
Executing iteration 0
Executing iteration 1
Skipping iteration 2
Executing iteration 3
Executing iteration 4

Explanation

  • The for loop iterates through the values from 0 to 4.
  • When i becomes 2, the continue statement skips the remaining code for that iteration.
  • As a result, the value 2 is not printed, and the loop continues with the next iteration.

Note: While using continue in loop, we have to make sure that we put the continue after the loop variable updation or else it will result in an infinite loop.

Goto Statement

The goto statement is used to transfer program control directly to a labeled statement within the same function.

  • Provides an unconditional jump to a specified label inside the function.
  • Commonly used to exit deeply nested loops or perform centralized error handling, though excessive use is discouraged as it reduces code readability.

Example

C
#include <stdio.h>

void checkEvenOrNot(int num) {
    if (num % 2 == 0)
        goto even;
    else
        goto odd;

even:
    printf("%d is even", num);
    return;
odd:
    printf("%d is odd", num);
    return;
}

int main() {
    int num = 26;
    checkEvenOrNot(num);
    return 0;
}

Output
26 is even

Flowchart of goto Statement

Flowchart-of-goto-Statement

Note: The use of goto is generally discouraged in the programmer's community as it makes the code complex to understand.

Return Statement

The return statement is used to terminate a function and transfer control back to the calling function, optionally returning a value.

  • Returns a value from a non-void function or simply exits a void function.
  • Immediately ends function execution, and any statements after the return statement are not executed.

Example

C
#include <stdio.h>

int add(int a, int b) {
    int sum = a + b;
    return sum; 
}

void printMessage() {
    
    printf("GeeksforGeeks\n");
    return; 
}

int main() {
    int result = add(5, 3);
    printf("Result: %d\n", result);

    printMessage();

    return 0;
}

Output
Result: 8
GeeksforGeeks

Explanation

  • The add() function takes two integers, adds them, and returns the result using the return statement.
  • In main(), the returned value is stored in the variable result and printed as Result: 8.
  • The printMessage() function is a void function, so return; is used only to terminate the function without returning any value.
  • Finally, return 0; in main() indicates that the program executed successfully and returns control to the operating system.
Comment