explain the significance of break statement in the switch statement
Answers
Answered by
2
C was one of the first languages to have the switch statement in this form, and all other major languages inherited it from there, mostly choosing to keep the C semantics per default - they either didn't think of the advantages of changing it, or judged them less important than keeping the behaviour everyone was used to.
As for why C was designed that way, it probably stems from the concept of C as "portable assembly". The switch statement is basically an abstraction of a branch table, and a branch table also has an implicit fall-through and requires an additional jump instruction to avoid it.
So basically, the designers of C also chose to keep the assembler semantics per default.
Similar questions
Computer Science,
4 months ago
Math,
4 months ago
Chemistry,
8 months ago
Physics,
8 months ago
India Languages,
11 months ago
English,
11 months ago
English,
11 months ago