Liitle help with boolean expressions

This is a discussion on Liitle help with boolean expressions within the C++ Programming forums, part of the General Programming Boards category; Well as you can tell im a noob when it comes to programming but I want to learn and am ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    2

    Liitle help with boolean expressions

    Well as you can tell im a noob when it comes to programming but I want to learn and am a little confuzed.Hope somebody aint to busy and can help me out.

    A. !( 1 || 0 ) ANSWER: 0
    B. !( 1 || 1 && 0 ) ANSWER: 0 (AND is evaluated before OR)
    C. !( ( 1 || 0 ) && 0 ) ANSWER: 1 (Parenthesis are useful)

    Im reading the lesson 2:If statements and dont get it much.

    The one I have trouble with is C.So if NOT is first right then the first 1 would evaluate to 0 hence false and then well it could not be true.

    Feel so nooby lol hope somebody can help and pardon my typos main language is spanish...THX

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,638
    Code:
    C. !( ( 1 || 0 ) && 0 ) ANSWER: 1
    When you evaluate boolean algebra, know what operations take precedence and work from the inside out, just like in math.
    Code:
    !(( 1 || 0 ) && 0 ) =
    !((1) && 0 ) =
    !(0) = 
    1

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    2
    Ah ok know I get it...thanks for your help really appriciate it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Novice needs help
    By ghaasemi in forum C++ Programming
    Replies: 9
    Last Post: 05-30-2009, 08:20 AM
  2. Stack that evaluates postfix expressions
    By killmequick in forum C Programming
    Replies: 7
    Last Post: 10-01-2008, 06:23 PM
  3. Regular expressions [Boost]
    By Desolation in forum C++ Programming
    Replies: 8
    Last Post: 12-30-2006, 09:10 PM
  4. Working with boolean...
    By CompiledMonkey in forum C Programming
    Replies: 4
    Last Post: 11-03-2003, 09:39 AM
  5. Use struct to create a boolean type
    By skyglin in forum C Programming
    Replies: 6
    Last Post: 06-18-2003, 08:21 PM

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