Developer community
0 votes
1.2k views
asked by Guru (24.6k points) 30 54 83 | 1.2k views

1 Answer

0 votes
Differences between 'break' and 'continue' statements

break continue

1. break is a keyword used to terminate the loop or

exit from the block. The control jumps to next

statement after the loop or block.

1. continue is a keyword used for skipping the current

iteration and go to next iteration of the loop

2.Syntax:

{

Statement 1;

Statement 2;

Statement n;

break;

}

2.Syntax:

{

Statement 1;

continue;

Statement 2;

}

3. break can be used with for, while, do- while, and switch statements. When break is used in nestedloops i.e. within the inner most loop then only the innermost loop is terminated.

3. This statement when occurs in a loop does not terminate it but skips the statements after this continue statement. The control goes to the next iteration. Continue can be used with for, while and do-while.

4. Example:

i = 1, j = 0;

while(i<=5)

{

i=i+1;

if(i== 2)

4. Example:

i = 1, j = 0;

while(i<=5)

{

i=i+1;

if(i== 2)

break;

j=j+1;

}

continue;

j=j+1;

}
answered by Guru (39.1k points) 10 22 36
edited by

Related questions

+1 vote
1 answer
0 votes
1 answer
asked by sara Guru (24.6k points) 30 54 83 | 124 views
0 votes
1 answer
0 votes
0 answers
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

3,751 questions
4,046 answers
117 comments
10,709 users