Hi
I wanted to know if there was a way to check if a variable was inside a set of values.
Like in the below given example, I want to know if n1 is either 5, 8, 27 or 2567
Is there a better way to do it than just using "if statement" ?
Thanks,Code:#include <iostream> int main() { int n1; if(n1 == 5 || n1 == 18 || n1 == 27 || n1 == 2567) //Is there a better way of achieving this std :: cout << "good\n"; else std :: cout << "bad\n"; return(0); }
Muthu




Reply With Quote