   any switch tricks?
  I'm dealing with needing a switch statement that covers large values.is there a way to write a switch/case statement (the case part more specifically) for say:int x;switch(x){case 1-10:<code>break;};I tried,case ((x>=0)&&(x<10)):this case doesn't seem to ever be justified, it's going with default with that.I also tried a for() statement, calling:for(int i=0;i<10;i++)case i:<code>;break;just to see, but that really makes the compiler mad.  I'd really rather not use so many if statements if at all possible, and writing out 30 or 40 case statements gets boring really fast.   
  int x;switch(x){case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:<code>break;};theTroll   ;  GCC (and maybe other compilers too) has an extension for "case with ranges". If you can't use this, you'll have to use "if".   ;Quote:Original post by protissI'd really rather not use so many if statements if at all possible, and writing out 30 or 40 case statements gets boring really fast.int x = ...;switch ( x / 10 ) {case 0: // 0 <= x < 10break;case 1: // 10 <= x < 20break;case 2: // 20 <= x < 30break;case 3: // 30 <= x < 40break;};  Thanks to both of you, much appreciated.   