+ 1

How do I make a "case" 3>= and <=6

that with that case carry out an action c++

29th May 2018, 12:14 AM
the crepex
the crepex - avatar
4 Answers
+ 5
You have two options, one using switch and other using if-else: switch(num) { case 3: case 4: case 5: case 6: doSomething(); break; } // this would be useful when your range is very small But, if the range is too large then, you have to go with if-else statements!
29th May 2018, 2:50 AM
777
777 - avatar
+ 3
the crepex just a warning: what Mohamed ELomari just posted is an extension of the GNU compiler and is not C++ standard. It will work with SoloLearn.
29th May 2018, 1:29 AM
Zeke Williams
Zeke Williams - avatar
29th May 2018, 1:11 AM
MO ELomari
MO ELomari - avatar
0
For what language? In some languages you cannot use a range of numbers for a switch; you have to use if else-if statements in a situation like that.
29th May 2018, 12:36 AM
Zeke Williams
Zeke Williams - avatar