Data type of case labels of switch statement in C++?
In C++ switch statement, the expression of each case label must be an integer constant expression.
For example, the following program fails in compilation.
Putting const before i makes the above program work.
Note : The above fact is only for C++. In C, both programs produce an error. In C, using an integer literal does not cause an error.
Program to find the largest number between two numbers using switch case:
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.