naseeam
asked on
Can case within switch statement specify range of values ?
signed short position;
switch (position)
{
case ( 500 to 1250)
{
/* set some variable */
break;
}
case (100 to 499)
{
/* set some variable */
break;
}
case (-200 to 99)
{
/* set some variable */
break;
}
default:
{
/* set some variable */
break;
}
}
If not, what other constructs can be used besides if - else ?
ASKER
could you provide example of placing multiple values in same block?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The C switch statement requires exact values, though you can place multiple values in the same block.
For what you're describing, the structure
if () else if ()
is probably the best.
Kent