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 case
s for a switch
statement?
Is the correct reason behind this:
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 that case
takes a constant. x==y
is usually not a constant.