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
optional
compulsory
not allowed. It gives an error message
to check an error
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
26 comments Page 2 of 3.

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.

Swati said:   9 years ago
I think break statement is a must in the switch for proper output.

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.

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.

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.

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.

Rahma said:   1 decade ago
I think if we do not use a break statement the code will be executed and compiler not gives error but the output will never be understandable by the user.

Prachi said:   1 decade ago
I think if we not write keyword after each case then all cases starting from first to last will execute, main thing is compiler not gives error, it is logical error.

Harikanth said:   1 decade ago
I did not get proper explanation can you suggest me in better way.

Diana said:   1 decade ago
If break is optional, then what is the purpose of using a switch statement?


Post your comments here:

Your comments will be displayed after verification.