Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 1 — Jump Statements

Lesson 7 of 32 in the free C Language notes on Siksha Sarovar, written by Rohit Jangra.

Jump Statements in C

Jump statements transfer control to another part of the program, breaking the normal sequential flow.

---

1. break

Exits the nearest enclosing loop or switch statement immediately.

for (int i = 1; i <= 10; i++) {
    if (i == 5) {
        break;       /* stops the loop when i = 5 */
    }
    printf("%d ", i);
}
/* Output: 1 2 3 4 */

In switch:

switch (x) {
    case 1:
        printf("One");
        break;   /* prevents fall-through */
    case 2:
        printf("Two");
        break;
}

---

2. continue

Skips the current iteration of a loop and moves to the next iteration.

for (int i = 1; i <= 10; i++) {
    if (i % 2 == 0) {
        continue;   /* skip even numbers */
    }
    printf("%d ", i);
}
/* Output: 1 3 5 7 9 */

---

3. goto

Transfers control unconditionally to a labelled statement in the same function.

#include <stdio.h>

int main() {
    int i = 1;
    
start:
    if (i <= 5) {
        printf("%d ", i);
        i++;
        goto start;
    }
    
    printf("\nDone");
    return 0;
}
/* Output: 1 2 3 4 5 */
Warning: goto makes code difficult to read and maintain. Avoid it in modern programming.

---

4. return

Exits the current function and optionally returns a value to the caller.

int add(int a, int b) {
    return a + b;   /* returns value and exits function */
}

int main() {
    int result = add(3, 4);
    printf("Result: %d\n", result);
    return 0;   /* exits main, 0 = success */
}

---

Summary Table

StatementScopeEffect
breakLoop / switchExits current loop or switch
continueLoopSkips current iteration
goto labelFunctionJumps to label
returnFunctionExits function with/without value