![]() |
VOOZH | about |
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: