Of course it can be implemented by a series of if()..else structures. One of the tenets of structured-programming is that it is a completely generic abstraction of computation and all programs could be written using only those constructs. That goes for a program that uses nothing but labeled gotos, which is good since that's how most programs are eventually implemented in hardware.I disagree.
Switch...case is a shortcut structure that could be implemented by a series of if...else structures.
Far, far more than just adding flexibility. The instances in which a switch() statement without any break statements within it is actually useful are very few and far between. Interestingly, if you draw the equivalent structured-programming flowchart of a switch statement having a break at the end of every case and one which has flow-through, the former is far cleaner than the latter in most instances.I’d like it if the break was not required, but it’s inclusion adds flexibility to the construct.
I'm far from certain that I understand quite what you mean here. If the switch() statement without break statements doesn't violate structured programming because an equivalent structure can be constructed using if()..else constructs, then how does the use of break statements within a switch() statement do so since an equivalent structure can also be constructed using if()..else constructs. What do you have in mind is required to violate or not violate structured programming standards?While the switch...case construct doesn’t violate structured programming standards, it flexibility allows this to happen.