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
Control statements
PPTX
C Programming Language Tutorial for beginners - JavaTpoint
PPTX
Decision making statements in C programming
PPTX
Loops in c
PPTX
Loops Basics
PPTX
Loops in c programming
PPSX
Break and continue
PPTX
Switch Case in C Programming
Control statements
C Programming Language Tutorial for beginners - JavaTpoint
Decision making statements in C programming
Loops in c
Loops Basics
Loops in c programming
Break and continue
Switch Case in C Programming

What's hot (20)

PPT
Class and object in C++
PPT
Function overloading(c++)
PPTX
Constructor in java
PPSX
C lecture 4 nested loops and jumping statements slideshare
PPTX
Control structures in java
PDF
Classes and objects
PPTX
Type casting in java
PPTX
Classes objects in java
PPTX
Inline function
PPTX
Interface in java
PPTX
File handling in c++
PPTX
Functions in c
PPT
Abstract class in java
PPTX
Packages in java
PPTX
Inheritance in java
PPTX
INLINE FUNCTION IN C++
PPTX
Applets in java
PPTX
Control Statements in Java
Class and object in C++
Function overloading(c++)
Constructor in java
C lecture 4 nested loops and jumping statements slideshare
Control structures in java
Classes and objects
Type casting in java
Classes objects in java
Inline function
Interface in java
File handling in c++
Functions in c
Abstract class in java
Packages in java
Inheritance in java
INLINE FUNCTION IN C++
Applets in java
Control Statements in Java
Ad

Similar to Jumping statements (20)

PPTX
C PPT.power point presentation about c pro
PPTX
C Programming Language Part 6
PPTX
C language 2
PDF
Control structure and Looping statements
DOCX
Looping statements
PDF
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
PPT
Introduction to C Programming
PPT
Control statements and functions in c
PPT
presentation_jumping_statements_.ppt
PPTX
Mca i pic u-3 handling input output and control statements
PPTX
handling input output and control statements
PPTX
Btech i pic u-3 handling input output and control statements
PPTX
C Programming Control Structures(if,if-else)
PPTX
Diploma ii cfpc u-3 handling input output and control statements
PDF
Controls & Loops in C
PPTX
Bsc cs pic u-3 handling input output and control statements
PPT
2. Control structures with for while and do while.ppt
PPTX
CONTROL STMTS.pptx
PPTX
C programming Control Structure.pptx
PPTX
C Programming Unit-2
C PPT.power point presentation about c pro
C Programming Language Part 6
C language 2
Control structure and Looping statements
Looping statements
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
Introduction to C Programming
Control statements and functions in c
presentation_jumping_statements_.ppt
Mca i pic u-3 handling input output and control statements
handling input output and control statements
Btech i pic u-3 handling input output and control statements
C Programming Control Structures(if,if-else)
Diploma ii cfpc u-3 handling input output and control statements
Controls & Loops in C
Bsc cs pic u-3 handling input output and control statements
2. Control structures with for while and do while.ppt
CONTROL STMTS.pptx
C programming Control Structure.pptx
C Programming Unit-2
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
Chapter 2 Digital Image Fundamentals.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
Electronic commerce courselecture one. Pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced Soft Computing BINUS July 2025.pdf
PPTX
Cloud computing and distributed systems.
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
KodekX | Application Modernization Development
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Chapter 2 Digital Image Fundamentals.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
20250228 LYD VKU AI Blended-Learning.pptx
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Understanding_Digital_Forensics_Presentation.pptx
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
Transforming Manufacturing operations through Intelligent Integrations
Electronic commerce courselecture one. Pdf
MYSQL Presentation for SQL database connectivity
Advanced Soft Computing BINUS July 2025.pdf
Cloud computing and distributed systems.
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
KodekX | Application Modernization Development
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Spectral efficient network and resource selection model in 5G networks
Bridging biosciences and deep learning for revolutionary discoveries: a compr...

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(); }