66.4k views
5 votes
On what previous language was C's switch statement based?

User Jeff Hardy
by
8.0k points

1 Answer

6 votes

Final answer:

The C language's switch statement was based on the case statement from the B language, which stemmed from BCPL.

Step-by-step explanation:

The C programming language's switch statement was based on the earlier case statement used in the language B, which was itself based on BCPL (Basic Combined Programming Language). BCPL influenced the development of B, which in turn influenced C. The switch statement provides an efficient way to dispatch execution to different parts of code based on the value of an expression, which is generally more efficient than a series of if-else statements.

User Joerg S
by
8.2k points