Switch , enter more values.

In switch how can i enter more than 1 value ? I mean i have a switch that has multiple cases and i want to execute 2 of them ..
1
2
3
4
5
6
7
8
9
10
11
12
13
int i ;
std::cin >> i ;

switch(i)
{
    case 1: case 2: case 3: case 4:
        std::cout << "positive, less than five\n" ; // 1, 2, 3 or 4
        break ;
        
    // ... other case labels
    
    default: ;
}
The question is .. Switch works only with a value ? Not more than one ?
What is it that you want to do?
if it is very complex you may need to pre-switch boil the cases down to something the switch can handle. You can do most things with fall-through, but it just depends... nested messy if-statements may also be required. Switches ... have limitations.
Last edited on
Topic archived. No new replies allowed.