Hi, new to these forums, intermediate self taught programmer, I have a question that could be considered an advanced use of the IF statement
Lets take the following example
if (a || b || c || d || e == 10)
then do something
In the above statement if any of 'a' 'b' 'c' 'd' 'e' are equal to 10, then the statement is TRUE. OK thats easy and straight forward.
However, what if more than one of 'a' 'b' 'c' 'd' 'e' are true, lets say a == 10 and c == 10, this statement again would still return TRUE, OK thats still easy and straight forward.
Now heres the trick i want to learn, I want to return TRUE only if a certain number of the inner variables meet the test, ie if two of the variables satisfy the test condition return TRUE otherwise return FALSE
Maybe something like this????
if ((a || b || c || d || e == 10) == 2)
ie if two of the variables == 10 then return TRUE otherwise return FALSE if 1 3 4 or all 5 are == 10,
I could certainly use individual IF statements for each parameter and count incrememmt each time one of them returns TRUE, but in the application i am developing this could mean quite extensive additional code and checking.
Is there a way of saying if 2 of the following 5 parameters meet the condition then return TRUE or FALSE. It could just as easily be if 3 or if 1 of the test variables, but the aim is to be able to stipulate for how many of the supplied variables is true or false
I hope this is clear(er than mud), many thanks for any help in advance