Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Help evaluating boolean number and arithmetic operators C++

  1. Sep 4, 2010 #1
    1. The problem statement, all variables and given/known data
    !( ((count<10) || (x<y)) && (count >=0) )
    where count is equal to 0


    2. Relevant equations
    i don't think any equations here are necessary except maybe the precedence law


    3. The attempt at a solution
    they combined 'and' and 'or' which confused the heck out of me. How do i figure out if this is true or false? if there is 'and' operator then wouldn't the whole thing have to be true, but the 'or' component means that only one of the expressions has to be true for the whole thing to be true. I am confused, how do i evaluate this? Do i negate last?
    thank you
     
    Last edited: Sep 4, 2010
  2. jcsd
  3. Sep 4, 2010 #2

    Filip Larsen

    User Avatar
    Gold Member

    To evaluate an expression like this, you need to know the precedence of the involved operators. In this case, parenthesis are heavily used, so you can start by evaluating the inner-most parenthesis containing expressions with "count" and then work your way outward to the next level of parenthesis in succession by employing the logic of the involved operators.

    If you loose track of all the parenthesis levels you may benefit from drawing the whole thing up as an expression tree first.
     
  4. Sep 4, 2010 #3
    that is what my professor told me, just to be sure i have it down, the inner most expression in this case would be the first expression? then the second expression containing count and then the last one?
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook