If a..g are contiguous constants / values ββof enum, just use range checking.
if (num >= a && num <= g) { do_something(); } else { do_something_else(); }
If they are non-contiguous but constant, then perhaps use the switch statement.
switch (num) { case a: case b: case c: case d: case e: case f: case g: do_something(); break; default: do_something_else(); break; }
otherwise, if it's just arbitrary variables or expressions, you just need to do it with a few tests.
Paul r
source share