CSA 4.8 DeMorgan's Answer Key, Station D

I was looking over the answer key to Unit 4, Lesson 8, DeMorgan’s and I found a curious issue. Depending upon how the student bracket out the parts of the equation, they will get two different end results for Station D. I’ve enclosed an example showing this. If the students bracket A || B to evaluate first, then && C to it, they will get a different result than if they evaluate B && C first, then || A. Is there a rule of thumb that they should evaluate the AND expression first, then the OR? In the image, I created two additional columns that the answer key did not have that shows what I am talking about. My students evaluated the expression from left to right which meant the evaluated the OR first, then the AND. The code that was being evaluated also showed parentheses around the OR expression. However the answer key shows for them to evaluate the AND first, then add the OR. I also looked at it using the Distributive property (IE: X(Y+Z) = XY + XZ) from back when I taught DeMorgan’s for a Digital Electronics course, but the answers don’t seem to match up either. Please help me understand how they got the answer they did on the answer key. Is there an error in the answer key or should the AND always be evaluated first?

Yes, in the order of operations AND && is evaluated before OR ||, unless there are parenthesis around it.

1 Like

Hi @slwilke! Thanks for posting this question to the forum. My students and I had this question as well and had to do a google search for it. We found the same answer that @yanet.cabrera posted. When evaluating logical operators, && has precedence over || unless there are parenthesis involved.

@yanet.cabrera, I love the graphic you included! I haven’t seen this but I’m definitely stealing it!

Best,
-Sam

1 Like