Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Chapter 3 we discussed decision structures and boolean expressions. Given the

ID: 3852268 • Letter: I

Question

In Chapter 3 we discussed decision structures and boolean expressions. Given the initial values for variables A, B, and C, what is the final value stored in variables output for each expression below?

boolean A = true;

boolean B = true;

boolean C = false;

boolean output;

output = !(A && B || C);   Answer is True or False?   _______________

output = !(A || B) || C;   Answer is True or False?   _______________

output = !A || B; Answer is True or False?   _______________

output = A && !(B || C); Answer is True or False?   _______________

output = !(!(A && !C));    Answer is True or False?

Explanation / Answer

output = !(A && B || C);         Answer is True or False?      _______________
Ans)False
this is how expression gets evaluated. (true && true || false) will evaluate to true whereas since negation is outside of the expression. It will be False

output = !(A || B) || C;             Answer is True or False?       _______________
Ans) False
The expression evaluates as follows. The negation of true is false and so false||false is false, so the answer is false
!(true||true) || false = False

output = !A || B;                      Answer is True or False?      _______________
Ans) True
The expression evaluates as follows. !true is false and || of false||true is true. Hence the result is True.
!true || true = True

output = A && !(B || C);        Answer is True or False?      _______________
Ans) False
The expression evaluates as follows. (true || false) is true whereas negation(!) outside of the expression makes it false. Then true && false which is False.
true && !(true || false) = true && false = False

output = !(!(A && !C));        Answer is True or False?
Ans) True. The expression evaluates as follows.
!(!(true && !false)) = !(!(true && true)) = !(!(true)) = !(false) = true