SlideShare a Scribd company logo
2
Most read
3
Most read
Jumping Statements: The jump statement unconditionally transfer program control within a
function. C language provides us multiple statements through which we can transfer the control
anywhere in the program.
There are basically 3 Jumping statements:
1. break jumping statements.
2. continue jumping statements.
3. goto jumping statements.

break statement: Sometimes, it is necessary to exit immediately from a loop as soon as the
condition is satisfied. The break statement terminates the execution of the enclosing loop or
conditional statement. In a for loop statement, the break statement can stop the counting when a
given condition becomes true. The break statement is a jump instruction and can be used inside a
switch construct, for loop, while loop and do-while loop. The execution of break statement
causes immediate exit from the concern construct and the control is transferred to the statement
following the loop. In the loop construct the execution of break statement terminates loop and
further execution of the program is reserved with the statement following the body of the loop
When break statement is used inside a loop, then it can cause to terminate from a loop. The
statements after break statement are skipped.

Syntax:
The syntax for a break statement in C is as follows:
break;

The break statement in C programming language has the following two usages:
1. When the break statement is encountered inside a loop, the loop is immediately
terminated and program control resumes at the next statement following the loop.
2. It can be used to terminate a case in the switch statement (covered in the next chapter).
If you are using nested loops (i.e., one loop inside another loop), the break statement will stop the
execution of the innermost loop and start executing the next line of code after the block.
You can see in the given example that the program is supposed to count the numbers from 1 to
20 using for loop. As per the condition defined the break statement stop the execution of the loop
as soon as it detects the number 5 .
#includes <stdio.h>
#include <conio.h>
void main () {
clrscr(); int n;
for (n=1; n<20; n++) {
printf("%dn", n);
getch();
if (n==5)
break;
}
}

continue statement
The continue statement in C programming language works somewhat like the break statement.
Instead of forcing termination, however, continue forces the next iteration of the loop to take
place, skipping any code in between.
For the for loop, continue statement causes the conditional test and increment portions of the
loop to execute. For the while and do...while loops, continue statement causes the program
control passes to the conditional tests.

Syntax:
The syntax for a continue statement in C is as follows:
continue;

The continue statement provides a convenient way to force an immediate jump to the loop
control statement. The break statement terminates the execution of the loop. As you can see in
the given example, we have used both the statements within the do while loop. The program
prompts the user to enter any number. If the number is less than 0, the break statement
terminates the execution of the loop. If the number is greater than 10, the continue statement
skips the value and jumps to the do while loop without terminating the loop. Otherwise, it will
print the entered number.
#include <stdio.h>
#include <conio.h>
void main()
{
int i;
clrscr();
for(i=1; i<=10; i++)
{
if(i==6)
continue;
printf("nt %d",i); // 6 is omitted
}
getch();}

goto Statement :
It is a well known as 'jumping statement.' It is primarily used to transfer the control of execution
to any place in a program. It is useful to provide branching within a loop.
When the loops are deeply nested at that if an error occurs then it is difficult to get exited from
such loops. Simple break statement cannot work here properly. In this situations, goto statement
is used. A goto statement in C programming language provides an unconditional jump from the
goto to a labeled statement in the same function.

Syntax:
The syntax for a goto statement in C is as follows:
goto label;
..
.
label: statement;

Here label can be any plain text except C keyword and it can be set anywhere in the C program
above or below to goto statement.
#include<stdio.h>
void main()
{
int a;
start:
printf("enter any no.");
scanf("%d", &a);
if(a<0)
goto start; a=a*a;//Goto statement A
printf("n %d", a);
getch();
}

More Related Content

PDF
Lecture 01 introduction to compiler
PPT
Unit 1 chapter 1 Design and Analysis of Algorithms
PPTX
Control Statements in Java
PPTX
Array and string
PPTX
sorting and filtering data in excel
PDF
Code optimization in compiler design
PPTX
Artificial intelligence in medical image processing
PPTX
Visual Communication
Lecture 01 introduction to compiler
Unit 1 chapter 1 Design and Analysis of Algorithms
Control Statements in Java
Array and string
sorting and filtering data in excel
Code optimization in compiler design
Artificial intelligence in medical image processing
Visual Communication

What's hot (20)

PPSX
C lecture 4 nested loops and jumping statements slideshare
PPTX
Templates in c++
PPSX
Break and continue
PPT
Strings Functions in C Programming
PPTX
While , For , Do-While Loop
PPTX
C Programming: Control Structure
PPTX
Loops c++
PPTX
control statements in python.pptx
PPTX
Control Statement programming
PPTX
C++ decision making
PPTX
Loops in C Programming Language
PPTX
Function in C program
PPT
Introduction to c programming
PPTX
Data types in python
PPT
Lecture 5 - Structured Programming Language
PDF
Time and Space Complexity
PPTX
Functions in c++
PPTX
Inheritance in c++
C lecture 4 nested loops and jumping statements slideshare
Templates in c++
Break and continue
Strings Functions in C Programming
While , For , Do-While Loop
C Programming: Control Structure
Loops c++
control statements in python.pptx
Control Statement programming
C++ decision making
Loops in C Programming Language
Function in C program
Introduction to c programming
Data types in python
Lecture 5 - Structured Programming Language
Time and Space Complexity
Functions in c++
Inheritance in c++
Ad

Similar to Jumping statements (20)

PDF
Unit 2=Decision Control & Looping Statements.pdf
PPTX
Decision statements in c language
PPTX
Decision statements in c laguage
PDF
PROBLEM SOLVING USING NOW PPSC- UNIT -2.pdf
PPTX
C Programming Language Part 6
PPT
2. Control structures with for while and do while.ppt
PPTX
C Programming Control Structures(if,if-else)
PDF
Controls & Loops in C
PPT
Ch3 repetition
PPTX
Introduction& Overview-to-C++_programming.pptx
PPTX
Introduction to C++ programming language
PDF
Cpp loop types
PPTX
Loops in c language
PPTX
Loops in c language
PPT
control-statements, control-statements, control statement
PPTX
Managing input and output operations & Decision making and branching and looping
PDF
CS305PC_C++_UNIT 2.pdf jntuh third semester
PDF
Chapter 3
PDF
Chapter 3 - Flow of Control Part II.pdf
PDF
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Unit 2=Decision Control & Looping Statements.pdf
Decision statements in c language
Decision statements in c laguage
PROBLEM SOLVING USING NOW PPSC- UNIT -2.pdf
C Programming Language Part 6
2. Control structures with for while and do while.ppt
C Programming Control Structures(if,if-else)
Controls & Loops in C
Ch3 repetition
Introduction& Overview-to-C++_programming.pptx
Introduction to C++ programming language
Cpp loop types
Loops in c language
Loops in c language
control-statements, control-statements, control statement
Managing input and output operations & Decision making and branching and looping
CS305PC_C++_UNIT 2.pdf jntuh third semester
Chapter 3
Chapter 3 - Flow of Control Part II.pdf
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Ad

More from Suneel Dogra (20)

PPT
Business model
PDF
Internet
PDF
PDF
Dreamweaver
PDF
Advanced html
PDF
PDF
File organisation
PDF
Distributed databases
PDF
Database models
PDF
Data base management system
PPT
Web sitedesignpart1
PPT
Web sitedesignpart1
PPT
Internet security
PDF
What is the linux
DOC
He 12 different types of servers that every techie should know about
PDF
Bachelor of computer application b.c.a.-2014
DOC
Cloud computing application
DOC
Fast track to linux
DOC
A sorted linear array
DOC
String in c
Business model
Internet
Dreamweaver
Advanced html
File organisation
Distributed databases
Database models
Data base management system
Web sitedesignpart1
Web sitedesignpart1
Internet security
What is the linux
He 12 different types of servers that every techie should know about
Bachelor of computer application b.c.a.-2014
Cloud computing application
Fast track to linux
A sorted linear array
String in c

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
Teaching material agriculture food technology
PDF
cuic standard and advanced reporting.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The AUB Centre for AI in Media Proposal.docx
Review of recent advances in non-invasive hemoglobin estimation
Mobile App Security Testing_ A Comprehensive Guide.pdf
Network Security Unit 5.pdf for BCA BBA.
Chapter 3 Spatial Domain Image Processing.pdf
Unlocking AI with Model Context Protocol (MCP)
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation_ Review paper, used for researhc scholars
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Building Integrated photovoltaic BIPV_UPV.pdf
Teaching material agriculture food technology
cuic standard and advanced reporting.pdf
Electronic commerce courselecture one. Pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

Jumping statements

  • 1. Jumping Statements: The jump statement unconditionally transfer program control within a function. C language provides us multiple statements through which we can transfer the control anywhere in the program. There are basically 3 Jumping statements: 1. break jumping statements. 2. continue jumping statements. 3. goto jumping statements. break statement: Sometimes, it is necessary to exit immediately from a loop as soon as the condition is satisfied. The break statement terminates the execution of the enclosing loop or conditional statement. In a for loop statement, the break statement can stop the counting when a given condition becomes true. The break statement is a jump instruction and can be used inside a switch construct, for loop, while loop and do-while loop. The execution of break statement causes immediate exit from the concern construct and the control is transferred to the statement following the loop. In the loop construct the execution of break statement terminates loop and further execution of the program is reserved with the statement following the body of the loop When break statement is used inside a loop, then it can cause to terminate from a loop. The statements after break statement are skipped. Syntax: The syntax for a break statement in C is as follows: break; The break statement in C programming language has the following two usages: 1. When the break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop. 2. It can be used to terminate a case in the switch statement (covered in the next chapter). If you are using nested loops (i.e., one loop inside another loop), the break statement will stop the execution of the innermost loop and start executing the next line of code after the block.
  • 2. You can see in the given example that the program is supposed to count the numbers from 1 to 20 using for loop. As per the condition defined the break statement stop the execution of the loop as soon as it detects the number 5 . #includes <stdio.h> #include <conio.h> void main () { clrscr(); int n; for (n=1; n<20; n++) { printf("%dn", n); getch(); if (n==5) break; } } continue statement The continue statement in C programming language works somewhat like the break statement. Instead of forcing termination, however, continue forces the next iteration of the loop to take place, skipping any code in between. For the for loop, continue statement causes the conditional test and increment portions of the loop to execute. For the while and do...while loops, continue statement causes the program control passes to the conditional tests. Syntax: The syntax for a continue statement in C is as follows: continue; The continue statement provides a convenient way to force an immediate jump to the loop control statement. The break statement terminates the execution of the loop. As you can see in the given example, we have used both the statements within the do while loop. The program prompts the user to enter any number. If the number is less than 0, the break statement terminates the execution of the loop. If the number is greater than 10, the continue statement
  • 3. skips the value and jumps to the do while loop without terminating the loop. Otherwise, it will print the entered number. #include <stdio.h> #include <conio.h> void main() { int i; clrscr(); for(i=1; i<=10; i++) { if(i==6) continue; printf("nt %d",i); // 6 is omitted } getch();} goto Statement : It is a well known as 'jumping statement.' It is primarily used to transfer the control of execution to any place in a program. It is useful to provide branching within a loop. When the loops are deeply nested at that if an error occurs then it is difficult to get exited from such loops. Simple break statement cannot work here properly. In this situations, goto statement is used. A goto statement in C programming language provides an unconditional jump from the goto to a labeled statement in the same function. Syntax: The syntax for a goto statement in C is as follows: goto label; .. . label: statement; Here label can be any plain text except C keyword and it can be set anywhere in the C program above or below to goto statement.
  • 4. #include<stdio.h> void main() { int a; start: printf("enter any no."); scanf("%d", &a); if(a<0) goto start; a=a*a;//Goto statement A printf("n %d", a); getch(); }