Thread: If Statements

  1. #1
    MikeG
    Guest

    If Statements

    Do you know how to set up a program where if you enter a number then you use IF and make it so if the integer is between two numbers it does one thing because when i try if(a>1,a<10), it messes up the program. Thank you.

  2. #2
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    howbout you try this:
    if(a<1 && a <10) //says 'if a is under 1 and(&&) a is under 10
    if(a<1 || a<10) // says 'if a under 1 or(||) a is under 10

    obviously you have to use the logical operations.

    && = and
    || = or

  3. #3
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Posts
    133
    And remember if you want it to be between 2 numbers, to use
    <=
    >=
    This way it will stop on those numbers. Otherwise it would stop one less than or one greater than a or b.
    C++ Is Powerful
    I use C++
    There fore I am Powerful

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. newbie question - if statements without conditions
    By c_h in forum C++ Programming
    Replies: 2
    Last Post: 07-18-2008, 10:42 AM
  3. Efficiency of case statements
    By Yasir_Malik in forum C Programming
    Replies: 26
    Last Post: 05-23-2006, 11:36 AM
  4. Class Function Members and If Statements
    By Team Shadow V2 in forum C++ Programming
    Replies: 10
    Last Post: 02-03-2005, 03:00 PM
  5. Switch statements for strings
    By cxs00u in forum C++ Programming
    Replies: 5
    Last Post: 04-17-2002, 03:38 PM