Help on Boolean Operators?

This is a discussion on Help on Boolean Operators? within the C++ Programming forums, part of the General Programming Boards category; I'm reading this tutorial about boolean operators, but i dont get one example: !( ( 1 || 0 ) && ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    10

    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
    Location
    While(1)
    Posts
    377
    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
    Location
    in front of my computer
    Posts
    804
    && 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.
    HOPE YOU UNDERSTAND.......

    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, 02:35 AM
  3. Bolean Operators hurt my head. (Trouble understanding) :(
    By Funcoot in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2008, 06:42 PM
  4. C++ and Boolean Operators
    By Rockskin in forum C++ Programming
    Replies: 3
    Last Post: 03-13-2006, 02:45 PM
  5. Boolean Operators?
    By civilwarsearch in forum C++ Programming
    Replies: 11
    Last Post: 12-15-2003, 08:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21