multi conditional if statements? [Archive] - C Board

PDA

View Full Version : multi conditional if statements?


chaser
07-26-2002, 07:11 PM
There's got to be a way to include more than one condition withing a single set of parentheses.. for instance

If (n==0) ...

I tried a few different distinguishers like commas, semicolon, even the & sign, and none work.

If (n==0, z==1, p==2) ...

What is it exactly that I must type? If there is no way, I'm a bit dissapointed because I like very much the ability to group conditions and have one else which is executed if any of the conditions are false.

red_baron
07-26-2002, 07:17 PM
if you want or its two vertical bars || and is 2 &&

ex.

if (b==0 || b==5)
-basically means if b is 0 or 5 do whats inside if statement.

if (b<100 && b> 50)
-basically means if b is less than 100 and greater than 50 then do whats inside if statment

chaser
07-26-2002, 08:07 PM
I knew there was more logic to that bit of syntax :D

Thanks I forgot that double operators are needed for conditions in c++

TechWins
07-26-2002, 10:52 PM
Chaser, considering that you posted this in the game forum, I don't think you should be making a game. If you don't have the very very basics down it is going to be extremely difficult for you to make a game. So I recommend (in fact urge) you to take more time learning the basics. You have a while before you are going to be ready to make any games, even if that game were a simple text tic-tac-toe game.:)