👤

Suppose that x, y, and z are int variables, and x = 10, y = 15, and z = 20.

Determine whether the following expressions evaluate to true or false.

Show your solution and write your answer in a short bond paper with your Name & Strand. (5 points each)

a. !(x > 10)

b. x <= 5 || y < 15

c. (x != 5) && (y != z)

d. x >= z || (x + y >= z)

e. (x <= y - 2) && (y >= z) || (z - 2 != 20)


Sagot :

a. !(x > 10)

x == 10, therefore !(10 > 10), which becomes !(false) which becomes true

Answer: true

b. x <= 5 || y < 15

x == 10 and y == 15, x <= 5 || y < 15 becomes 5 <= 5 || 15 < 15 which becomes true || false, which becomes true

Answer: true

c. (x != 5) && (y != z)

x == 10, y == 15 and z == 20, (x != 5) && (y != z) becomes (10 != 5) && (15 != 20), which becomes (true) && (true), which of course is true.

Answer: true

d. x >= z || (x + y >= z)

x == 10, y == 15 and z == 20,  x >= z || (x + y >= z) becomes 10 >= 20 || (10 + 15 >= 20, which becomes false || (25 >= 20) which becomes false || true, which simplifies to true.

Answer: true

e. (x <= y - 2) && (y >= z) || (z - 2 != 20)

x == 10, y == 15 and z == 20, (x <= y - 2) && (y >= z) || (z - 2 != 20) becomes (10 <= 15 - 2) && (15 >= 20) || (20 - 2 != 20), which becomes (10 <= 13) && (false) || (18 != 20), which becomes (true) && (false) || (true), which becomes false || true, which becomes true.

Answer: true