Is it possible... (making or/and statements with 3+ variables)

The key thing with logic statements like “or” and “and” is to give CS no more than 2 things to deal with at a time.

Anything in parentheses counts as one thing. So if you’ve got three things, tuck two of them in an extra parenthesis to turn them into one thing. That’s what I’ve done in the example above, turning two things

(var1 = 1) or (var2 = 1)

into one

((var1 = 1) or (var2 = 1))

If you wanted to take a fourth variable into account, just plop everything you’ve got so far inside another parenthesis to make it just one thing:

(((var1 = 1) or (var2 = 1)) or (var3 = 1))

and add your new second thing:

*if (((var1 = 1) or (var2 = 1)) or (var3 = 1)) or (var4 =1)

That should allow you to add as many “or” statements as you have time for.

7 Likes