+ 1
How do I make a "case" 3>= and <=6
that with that case carry out an action c++
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!
+ 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.
+ 2
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.