Since, there is no true false boolean type in C, what does the expression x == y evaluate to, when it's true and when it's false?
If it evaluates to 1 and 0 respectively, which are integers, why can't we use such expressions as cases for a switch statement?
Is the correct reason behind this:
- case allows only integer expressions or expressions that evaluate to integers and x == y wouldn't evaluate to an integer (which I don't see how)? or
- if switch allowed such expressions as cases there is a good chance that mutiple cases will end up having the same value, i.e., whenever
x==y, we'll get a 1, so multiple such cases will evaluate to 1, or 0; which can't be allowed in switch statements.
The reason is not the type of
x==y, but the fact thatcasetakes a constant.x==yis usually not a constant.