Computer Science - Object Oriented Programming Using C++ - Discussion
Discussion Forum : Object Oriented Programming Using C++ - Section 1 (Q.No. 5)
5.
The use of the break statement in a switch statement is
Discussion:
26 comments Page 2 of 3.
K.lalitha said:
1 decade ago
In some cases it is optional and in some cases it is compulsory. If we use break statement where the condition is true then the next conditions will not execute.
Maanasi said:
1 decade ago
Including break in action block in order to exit from the switch statement. If you don't use a break statement, the program will just continue into the next case block.
In case if one needs to exit from the current case break statement is compulsory if not it is optional.
In case if one needs to exit from the current case break statement is compulsory if not it is optional.
Qamar said:
1 decade ago
Its optional in the sense that it is allowed in the language to skip break statement and compiler will not raise an error.
SIRAGIRI said:
10 years ago
In case if one needs to exit from the current case break statement is compulsory if not it is optional.
Swati said:
9 years ago
I think break statement is a must in the switch for proper output.
Kajal said:
9 years ago
The keyword break is compulsory in switch statement because switch statement is not fulfil without break. The syntax of switch statement contains break so if we are not write the break in switch statement then syntax must be wrong.
I think we should consider this.
I think we should consider this.
Hemkant said:
9 years ago
It's possible to use the switch case in function which returns the value, based upon choice in the switch, you can return from the case in this situation function will be returned without any need of the break.
int fun(int choice)
{
switch(choice){
case 1 :
return 1;
case 2 :
return 2;
default
return 3;
}
}
int fun(int choice)
{
switch(choice){
case 1 :
return 1;
case 2 :
return 2;
default
return 3;
}
}
Renuka said:
8 years ago
Use of break statement in a switch statement is compulsory.
Sandesha said:
8 years ago
Exactly, The Break statement is mandatory in switch concept.
Sasi said:
8 years ago
In the syntax also break is given know, so it may be compulsory.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers