![]() |
| Jump Statement in C Programming | Complete Guide for Beginners |
Jump Statement Definition in C
Jump Statement: A jump statement in C is a control flow statement that allows the program to jump to a different part of the code. It is used to transfer the control from one point to another point in the program. Jump statement can be used only looping operation like for , while and do-while loop.
Types of Jump Statement in C
- break Statement in C
- continue Statement in C
- goto Statement in C
- return Statement in C
Break Statement in C Programming
Break Statement: A break statement can be used to exit a loop or switch statement prematurely. It is used to transfer the control out of the body of loop. In other word we can say that it terminates the current loop. Break statement are mostly used with loop(for, while, do while) and switch statement. The break statement immediately exits the current loop or loop or switch statement. Break terminates the entire loop and transfer control to the statement after the loop.
Syntax of break Statement in C
{ if(condition){ break; } body Statements; } |
Example of Break Statement in C
| #include<stdio.h> void main(){ clrscr(); for(int i=1;i<=5;i++) { if(i==4){ break; } printf("Your Number is:%d\n",i); } getch(); } ============OUTPUT============ Your Number is:1 Your Number is:2 Your Number is:3 |
Example of Without Using Break Statement
| #include<stdio.h> void main(){ clrscr(); for(int i=1;i<=5;i++) { printf("Your Number is:%d\n",i); } getch(); } ============OUTPUT============ Your Number is:1 Your Number is:2 Your Number is:3 Your Number is:4 Your Number is:5 |
Continue Statement in C Programming
Continue Statement: A continue statement can be used to skip the current iteration of a loop and proceed to the next iteration. It is used to skip the next statement and continue the loop. Continue statement are mostly used with loop(for, while, do while).
The continue statement skips the current iteration and moves to the next one. Continue is a skip remaining statement in current iteration and move to the next iteration.
Syntax of Continue Statement in C
{ if(condition){ continue; } body Statements; } |
Continue Statement Example Program in C
| #include<stdio.h> void main(){ clrscr(); for(int i=1;i<=5;i++) { if(i==3){ continue; } printf("Your Number is:%d\n",i); } getch(); } ============OUTPUT============ Your Number is:1 Your Number is:2 Your Number is:4 Your Number is:5 |
Example of Continue Statement in C
| #include<stdio.h> void main(){ clrscr(); int s; for (s=1;s<=10; s++) { if (s%3==0) { continue; } printf("Check Homework of Student:%d\n",s); } getch(); } ============OUTPUT============ Check Homework of Student:1 Check Homework of Student:2 Check Homework of Student:4 Check Homework of Student:5 Check Homework of Student:7 Check Homework of Student:8 Check Homework of Student:10 |
Define Goto Statement with Example
Goto Statement: A goto statement can be used to alter the normal sequence of program execution by transferring control to some other part of the program. In its general for the goto statement is written as goto label. The goto statement provides an unconditional jump from one point to another point in the program. While its part of the C language its use is generally discouraged in modern programming due to its impact on code readability and maintainability.Syntax of Goto Statement in C
//Label Definition Label: body Statements; |
Example of Goto Statement in C Language
| #include<stdio.h> void main(){ clrscr(); int n,i=1; printf("Enter any number:"); scanf("%d",&n); table: printf("%d X %d=%d\n",n,i,i*n); i++; if(i<=10) goto table; getch(); } ============OUTPUT============ Enter any number:8 8 X 1=8 8 X 2=16 8 X 3=24 8 X 4=32 8 X 5=40 8 X 6=48 8 X 7=56 8 X 8=64 8 X 9=72 8 X 10=80 |
Return Statement in C Programming
Return Statement: A return can be used to exit from a method and optionally return a value to the method caller. Return statement terminates the current function and transfer the control to the calling function. We can also use return statement to transfer value from one function to another.
Example of Return Statement in C
| #include<stdio.h> int Jiocoding(){ int a=30,b=50; int c=a+b; return c; } int main(){ clrscr(); int res=Jiocoding(); printf("Result is:%d",res); getch(); } ============OUTPUT============ Result is:80 |

