Can a Switch/Case statement have AND, NOT and OR in it? As in:
etc.Code:switch (a) case 1 && c!=4:
Can a Switch/Case statement have AND, NOT and OR in it? As in:
etc.Code:switch (a) case 1 && c!=4:
no...why would u need it?
case:
break;
case:
break;
etc....for every condition u have a case. I think what your looking for is an if:
if (1 && c!=4) //psudo code
To check to see if a variable equals the input, but isn't already assigned to something else.
When i said why would u need it, was because the thing your attempting doesnt call for a switch, or isnt what a switch will do.
Ok, I just thought a switch would be easier than many, many, many IF statements. What would be faster? I was thinking, if I stored a bunch of variables in an array, is there any way to compare the input to every variable in the array to see if they match, without using IFs?
you dont have to hard code all of the ifs, use a loop...
Code:for(int i=0; i < arrayLength; i++) { if(array[i] == input) cout << "Yay, array at " << i << "equals input!"; }
Thanks!