CS 116
Oct. 23, 2000
Assuming the following values:
int x = 11; int y = 6; int z = 1; char c = 'k'; /* 'k' = 107 */ char d = 'y'; /* 'y' = 121 */fully parenthesize and evaluate the following expressions. Assume that the ASCII character representation is used.
x > 9 && y != 3
((x > 9) && (y != 3)) (true && true) true
x == 5 || y != 3
((x == 5) || (y != 3)) (false || true) true
!(x > 14)
(!(x > 14)) (!false) true
!(x > 9 && y != 23)
!(((x > 9) && (y != 23))) !((true && true)) !(true) false
x <= 1 && y == 6 || z < 4
(((x <= 1) && (y == 6)) || (z < 4)) ((false && true) || true) (false || true) true
c >= 'a' && c <= 'z'
'a' = 97, 'z' = 122
((c >= 'a') && (c <= 'z')) (true && true) true
c >= 'A' || c <= 'Z'
'A' = 65, 'Z' = 90
((c >= 'A') || (c <= 'Z')) (true || false) true
c != d && c != '\n'
'\n' = 10
((c != d) && (c != '\n')) (true && true) true
5 && y != 8 || false
((5 && (y != 8)) || false)Invalid expression: can't convert 5 to
boolean
.
x >= y >= z
((x >= y) >= z)Invalid expression: can't convert boolean (
(x >= y)
) to int
.