Thread: Help on Boolean Operators?

  1. #1
    Registered User
    Join Date
    Dec 2009

    Question Help on Boolean Operators?

    I'm reading this tutorial about boolean operators, but i dont get one example:
    !( ( 1 || 0 ) && 0 )
    . The tutorial says that the AND must be evaluated before OR, yet I see the OR before the AND in the example. Can someone clarify to me why the answer is 1? (1 as in TRUE.) And it also says to learn Boolean Algebra...

  2. #2
    Registered User
    Join Date
    Oct 2009
    Which you read is correct the book/ tutorial was talkin about the operator precedence. in the above example its just a usage

  3. #3
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    in front of my computer
    && has a higher precedence than ||, but () has even higher precedence than any operator, so the thing between the parentheses() is evaluated first, which is 1||0(result 1), then 1&&0(result 0) and lastly !0=1. Even ! has the precedence higher than && or || but still because of () this order is taken.

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior

    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Boolean Operators...
    By Nean in forum C++ Programming
    Replies: 8
    Last Post: 10-06-2009, 02:31 AM
  2. boolean operators
    By forkpie hat in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2008, 03:35 AM
  3. Bolean Operators hurt my head. (Trouble understanding) :(
    By Funcoot in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2008, 07:42 PM
  4. C++ and Boolean Operators
    By Rockskin in forum C++ Programming
    Replies: 3
    Last Post: 03-13-2006, 03:45 PM
  5. Boolean Operators?
    By civilwarsearch in forum C++ Programming
    Replies: 11
    Last Post: 12-15-2003, 09:50 PM