Given the declarations for a and b, what value does the Boolean(conditional) exp
ID: 3613504 • Letter: G
Question
Given the declarations for a and b, what value does the Boolean(conditional) expression evaluate to? You MUST show your work!
int a = 4;
int b = -3;
!(!(a == 4 && b == -3) && (6 <= 3 || a > 1))&& true || false || (b > (5 - 10) || !(a > 0))
Explanation / Answer
You should probably start by breaking down each statement into thebasic values true and false. We know a == 4 is true, and b == -3 is true, so (a ==4 && b== -3) evaluates to true according to how logical ANDs work. Butthis is inverted due to the !, so it is turned into false. 6 is not less than or equal to three, so that evaluates to false. ais greater than one, so that evaluates to true, and causes theoverall OR statement to be true. So now, we have !(false && true && true || false || (b > (5 -10) || !(a >0)) b is greater then -5, so that's true. a is > 0, so that's alsotrue--if it weren't inverted. So now it's false. Since they areboth in parentheses with an OR statement is between them, theoverall statement is now false. !(false && true && true || false || false) Now it's cake. False and true and true evaluate to false. !(false || false || false) False OR false is false. Do that twice. !(false) The inversion of false is true. true (final answer)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.