Thread: Problem with boolean operators

  1. #1
    Registered User
    Join Date
    Sep 2009

    Problem with boolean operators


    I have a problem with the boolean operators.
    On the end of the second part of the C beginner tutorial I was going to quiz.
    I was ready for the answers of the quiz but I had it wrong!
    This Code:
    !(1 && !(0 || 1)).
    Seems to be true and I tought it was false.
    But I dont really get it.
    The AND goes before OR but the OR is between two paranthesis so it goes first.
    Before the paranthesis is an NOT sign but does 0 evaluate to 1 or does 1 evaluate to 0. I see a NOT sign but I dont know wich evaluates the first number immideatly afther the NOT thing? or another?
    I need to know that first otherwise I dont get the whole C program and I get stuck.


  2. #2
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    in front of my computer
    The steps are as follows
    1. 0||1 = 1
    2. !1 = 0
    3. 1&&0=0
    4. !0 =1

    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

  3. #3
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    a = 0 || 1; because of parentthesis
    b = !a; because of preferencies

    c = 1 && b; because of parenthesis

    d = !c;
    To be or not to be == true

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  2. problem with relational operators
    By manoncampus in forum C++ Programming
    Replies: 10
    Last Post: 12-13-2005, 07:15 PM
  3. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM