passing multiple values to switch separating the values by commas
Can I pass multiple values to the switch case statement separating
different values by commas ? what would the expression evaluate to? If no
error occurs, which of the multiple values would the compiler evaluate the
switch with ? Keeping in mind the low precedence of the comma operator?
say for instance i write the code as follows:
int m=10;
switch(m, m*2)
{
case 10: printf("\n case 10");
case 20: printf("\n case 20");
case 30: printf("\n case 30");
default: printf("\n no case");
}
No comments:
Post a Comment