saving multiple values to variable

Hey guys, how can I make a variable equal to multiple values. For example basic is x = 5; but Is it possible for x to be equal to 5, 7, 8 or 10?
x=(5||7||8||10);
so for example when my code does this

int a=4

if(a==x)
{
do this
}
else
{
do that
}

so my code wont work unless a is 5, 7, 8 or 10.

My project is a car parking lot managment system, which reqires the customer to enter mobilenumber on keypad and when that number is confirmed by the keypad a random 11 digit code is sent to the mobile via sms (sim800L GSM). The cutomer will then use that code from his phone to exit the parking lot.

No. Code does not work like that. A variable can only hold a single value. You can have an array which hold multiple values, but you have to iterate over the array to see if a given number is in the array.

int xArray[] = { 5,7,8,10 };
const int nElements = sizeof(xArray) / sizeof(xArray[0]);

int a=4;

for( int idx=0; idx < nElements; idx++) {
  if ( xArray[idx] == a ) {
    // do something
  }
}

I would have it look to see if x is equal to one of those numbers, and increase the value of x till it meets that number.

So have it look something like this,

if (a == x && x == 5 || /etc.../){

do this
} else {

x++;
}

Or you could make x an array so it can hold those values. You would set the length then starting at 0, 0 is the first place holder in an array, to one of the values you need. I can't really write it out since I'm fairly new to using arrays but it's idea that some one else could develop for you.

Also what is the point of this project as it may help us provide a better answer for you?

SpasmaticAA:
I would have it look to see if x is equal to one of those numbers, and increase the value of x till it meets that number.

So have it look something like this,

if (a == x && x == 5 || /etc.../){

do this
} else {

x++;
}

Or you could make x an array so it can hold those values. You would set the length then starting at 0, 0 is the first place holder in an array, to one of the values you need. I can't really write it out since I'm fairly new to using arrays but it's idea that some one else could develop for you.

Also what is the point of this project as it may help us provide a better answer for you?

My project is a car parking lot managment system, which reqires the customer to enter mobilenumber on keypad and when that number is confirmed by the keypad a random 11 digit code is sent to the mobile via sms (sim800L GSM). The cutomer will then use that code from his phone to exit the parking lot.

blh64:
No. Code does not work like that. A variable can only hold a single value. You can have an array which hold multiple values, but you have to iterate over the array to see if a given number is in the array.

int xArray[] = { 5,7,8,10 };

const int nElements = sizeof(xArray) / sizeof(xArray[0]);

int a=4;

for( int idx=0; idx < nElements; idx++) {
 if ( xArray[idx] == a ) {
   // do something
 }
}

This one works perfect thanks genius. If you dont mind, check out my post again i updated it, if you just scroll to the bottom I exaplained my project. Now that I know this array feature work, is it possible to add to this array everytime I receice a new value.

2donboi2:
This one works perfect thanks genius. If you dont mind, check out my post again i updated it, if you just scroll to the bottom I exaplained my project. Now that I know this array feature work, is it possible to add to this array everytime I receice a new value.

You can change the values of the numbers in the array but you cannot add more numbers to it. That is to say if I wanted to add a one to the array and make the array longer I don't think it will work based off my understanding of arrays in java which behave similarly. I would look at the array section on the arduino reference page.