Comp Sci Help evaluating boolean number and arithmetic operators C++

Click For Summary
To evaluate the boolean expression !( ((count<10) || (x<y)) && (count >=0) ) with count equal to 0, understanding operator precedence is crucial. Start by evaluating the innermost parentheses, focusing on the expressions involving "count" first. The combination of 'and' and 'or' can be confusing, as 'or' allows for one true condition while 'and' requires all conditions to be true. Constructing an expression tree can help visualize the evaluation process and maintain clarity on the levels of parentheses. Properly following these steps will lead to determining the truth value of the entire expression.
ihatecats2014
Messages
30
Reaction score
0

Homework Statement


!( ((count<10) || (x<y)) && (count >=0) )
where count is equal to 0

Homework Equations


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

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:
Physics news on Phys.org
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.
 
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?
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 14 ·
Replies
14
Views
5K
  • · Replies 13 ·
Replies
13
Views
4K
Replies
4
Views
2K