Discussion of Activity 2.4 - Understanding relational and logical operators

Here are our example solutions. Notice that we only changed one operator in each expression, but there are other solutions.

Original Expression New Expression Actual Change
p = (A < C) && D; p = (A > C) && D; // change the < to >
q = (A != B + C) || (B == C); q = (A == B + C) || (B == C); // change != to ==
r = (4 < C) && (A != 16); r = (4 <= C) && (A != 16); // change < to <=
s = !D && ((A != B) && (4 >= C)); s = !D || ((A != B) && (4 >= C)); // change the first && to ||
t = !((A != B) && (B > C)); t = !((A != B) && (B < C)); // change > to <
u = p && ((B == (A - C)) || !D); u = p || ((B == (A - C)) || !D); // change && to ||

The last expression only evaluates to true if you you have set p to true earlier, as required by the activity.