0% found this document useful (0 votes)
35 views

CM304

The document discusses break and continue statements in loops. It provides: 1) The definition and usage of break statements to immediately terminate a loop along with a flowchart and example. 2) The definition and usage of continue statements to skip the current iteration of a loop along with a flowchart and example. 3) A comparison of the differences between break and continue statements.

Uploaded by

api-3849444
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

CM304

The document discusses break and continue statements in loops. It provides: 1) The definition and usage of break statements to immediately terminate a loop along with a flowchart and example. 2) The definition and usage of continue statements to skip the current iteration of a loop along with a flowchart and example. 3) A comparison of the differences between break and continue statements.

Uploaded by

api-3849444
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name of the faculty : V.Rajendra Prasad.
Designation : Lecturer.
Branch : Computer Engineering
Institute : V.K.R & V.N.B Polytechnic, Gudivada
Year/Semester : III Semester
Subject : UNIX & C
Subject Code : CM-304
Topic : Understand repetitive structures.
Duration : 50 Min
Sub Topic : Break and continue statements..
Teaching Aids : Diagram and animations, PPTs.
CM304.52TO53 1
Objective

On completion of this period, the student would


be able to know.

 break and continue statement.

CM304.52TO53 2
Recap

 Loop statements
 While loop
 Do-while loop
 For loop

CM304.52TO53 3
break and continue statements

Break statement:

Break is used to terminate a loop


[Immediate exit from the loop].

The Break statement is normally


used in loop and switch statements.

CM304.52TO53 4
Flowchart for of break statement
Enter input loop

Loop false
condition

true
loop
statement

yes Out of loop


break
no

CM304.52TO53 5
Simple program using break
#include<stdio.h>
main( )
{
int n;
printf (“Enter the number”);
scanf (“%d”, &n);
while (n<10)
{
if (n==3)
{
printf(“ using break statements”);
break;
}
printf(“number =%d \n”,n);
}
}

CM304.52TO53 6
continue statement

 continue statement is used to skip a part of

the loop and execute the loop again from


the beginning .
 It is used in while, do..while and for loops only.

CM304.52TO53 7
Flowchart for of continue statement
Enter the loop

Loop condition false


Exit the loop

true

statement

Yes
continue
No
statement

CM304.52TO53 8
Simple program using continue
#include<stdio.h>
main( )
{
int marks , i=1,sum=0;
clrscr( );
while(i<=10)
{
printf (“Enter the marks”);
scanf (“%d”,&marks);
if (marks<0|| marks>100)
continue;
sum= sum + marks;
i=i+1;
}
}

CM304.52TO53 9
Difference between break and continue

BREAK CONTINUE
 Exit from
form the loop  It will skip the current
immediately. iteration and begin the
next iteration of the
loop.
 syntax is break;  Syntax is continue;

 used in while, do-  used in while, do-


while, for and switch. while and for loops
only.
CM304.52TO53 10
10
Summary

 The break statement, general syntax,


flowchart and example.
 The continue statement, general syntax,
flowchart and example.

 Difference between break and continue


statements.

CM304.52TO53 11
Quiz

1. break is used to..?


a) break used to terminate the execution
of the loop.
b) break is used to skip the execution of loop
by one statement.
c) break used to stop the execution of the
program.

CM304.52TO53 12
Quiz

1. break is used to..?


a) break used to terminate the execution
of the loop.
b) break is used to skip the execution of loop
by one statement.
c) break used to stop the execution of the
program.

CM304.52TO53 13
Quiz

2.In the following where is the break statement


used?
a) Only for loop.
b) do-while, while, for and switch.
c) for and while.

CM304.52TO53 14
Quiz

2.In the following where the break statement is


used?
a) Only for loop.
b) do-while, while, for and switch.
c) for and while.

CM304.52TO53 15
Quiz
3. continue is used to..?
a) used to skip some set of
instructions
in the loop.
b) used to execute continuously the

entire loop.
c) none of the above.

CM304.52TO53 16
Quiz
3. continue is used to..?
a) used to skip some set of
instructions
in the loop.
b) used to execute continuously the

entire loop.
c) none of the above.

CM304.52TO53 17
Quiz

4. In the following where the continue


statement
is used?
a) do-while, while and for only.
b) do-while, while, for and switch.
c) Switch only.

CM304.52TO53 18
Quiz

4. In the following where the continue


statement
is used?
a) do-while, while and for only.
b) do-while, while, for and switch.
c) Switch only.

CM304.52TO53 19
Frequently Asked Questions

1. Explain ‘break’& ’continue’ statements.


2. Differentiate between ‘break’ & ‘continue’
statements.

CM304.52TO53 20

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy