Like Tree4Likes
  • 1 Post By std10093
  • 3 Post By std10093

Boolean question - Jumping into C++ C4. IF Statments Q3 (spoiler)

This is a discussion on Boolean question - Jumping into C++ C4. IF Statments Q3 (spoiler) within the C++ Programming forums, part of the General Programming Boards category; Hi all Firstly thanks for any advice, i have tried a number of searches but i am not getting anything ...

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    3

    Boolean question - Jumping into C++ C4. IF Statments Q3 (spoiler)

    Hi all

    Firstly thanks for any advice, i have tried a number of searches but i am not getting anything relevant. I have also taken a look at truth tables and can break the expression down to evaluate each component correctly. The following question, ask us to evaluate the following

    !( true && ! (false || true ))

    The bit i am stuck with is very simple and i feel somewhat foolish even asking its how do i treat the part "&& !" is this a logical nand although that does no feel right because the AND is before the NOT?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    2,147
    the ! applies to the parenthetical phrase following it. so it effectively becomes !(true && (!(false || true)))

  3. #3
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Glyfada,Athens
    Posts
    2,650
    It's a matter of which operator will be applied first.

    But...before starting writing my explanation... did you try to transform this into code and run it?
    laserlight likes this.
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

  4. #4
    Registered User
    Join Date
    Jun 2010
    Posts
    3
    Thanks Elkvis, i did take it that way and indeed it works out correctly but i felt uneasy about my understanding of the expression and the trouble with boolean is you have a 50 50 chance of getting it correct which really unsettled me.

    std10093 i have not turned it into code in truth i got a little bit fixated with it, and went off on a tangent, but i think i will take a look at that now..

  5. #5
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Glyfada,Athens
    Posts
    2,650
    Your target is to program. The program runs on the computer. If the output says 0 and I say 1, then I am wrong. The computer is the GOD in this case :P

    So, always ask him

    Also, welcome to the forum
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

  6. #6
    Registered User
    Join Date
    Jun 2010
    Posts
    3
    Thank you std10093,

    I have to say i am really enjoying the book, and thanks for the quick responses, i can now move on

  7. #7
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Glyfada,Athens
    Posts
    2,650
    You are welcome. Programming is not taught by books only. You need to write code too

    Good reading...!
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SPOILER tags please?
    By C_ntua in forum General Discussions
    Replies: 3
    Last Post: 03-10-2011, 10:47 AM
  2. Quick question on if statments
    By UCFuser in forum C Programming
    Replies: 7
    Last Post: 02-11-2011, 09:51 PM
  3. Boolean statments
    By dparker in forum C++ Programming
    Replies: 5
    Last Post: 04-09-2010, 02:59 PM
  4. No Country for Old Men (spoiler alert)
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 04-29-2008, 09:38 AM
  5. The Non-Spoiler Ep II thread.
    By Scourfish in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-17-2002, 09:43 AM

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