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 3 of 3.

Soujanya said:   1 decade ago
I think it is compulsory because if we use break statement we will get proper output otherwise all the statements get executed.

Wasif said:   1 decade ago
Its not compulsory becouse when we want to prform same task for multiple cases in single itteration at that time there is no need use break statement for each case.

Eg:.

As + and - having same priority & * and / has same priority we can write.

Switch (operator).
Case +:.
Case -:.
Return 1;.
Break;.
Case *:.
Case /:.
Return 2;.
Break;.

MRT said:   1 decade ago
I though this is compulsory. because we never use break option then. it execute all statement and if i use default option the it always execut and may be give wrong result ...!

Manisha said:   1 decade ago
Actually it's compulsory for proper output if we not written it then we not got proper output.

Sonu said:   1 decade ago
If you not write it, it will ok, but all statements from other cases also get executed.

Sharda said:   1 decade ago
How can it b optional? please let me know.


Post your comments here:

Your comments will be displayed after verification.