Thread: multi conditional if statements?

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    10

    multi conditional if statements?

    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.
    chaser

  2. #2
    Registered User red_baron's Avatar
    Join Date
    May 2002
    Posts
    274
    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
    ¿Red Baron?

    "Imagination is more important than knowledge"
    -Albert Einstein (1879-1955)

    Check out my games!

    [code] /* dont forget code tags! */ [/code]

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    10

    Ah, thanks

    I knew there was more logic to that bit of syntax

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

  4. #4
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Conditional Statements
    By strokebow in forum C Programming
    Replies: 30
    Last Post: 11-22-2006, 06:08 PM
  3. problem with floats in conditional statements
    By Desolation in forum C Programming
    Replies: 3
    Last Post: 07-08-2006, 01:56 AM
  4. Using floats in conditional statements
    By DBB in forum C++ Programming
    Replies: 3
    Last Post: 09-12-2001, 07:54 AM