Operator Precedence and Associativity Worksheet

CS18

February 7, 1996

Assuming the following values:

int x = 11;
int y = 6;
int z = 1;
char c = 'k';
char d = 'y';
fully parenthesize and evaluate the following expressions. Assume that the ASCII representation is used (you may need to refer to Appendix C in Uckan).

  1. ((x > 9) && (y != 3)) -> 1

  2. ((x == 5) || (y != 3)) -> 1

  3. !((x > 14)) -> 1

  4. !(((x > 9) && (y != 23))) -> 0

  5. (((x <= 1) && (y == 6)) || (z < 4)) -> 1

  6. ((c >= 'a') && (c <= 'z')) -> 1

  7. ((c >= 'A') || (c <= 'Z')) -> 1

  8. ((c != d)) && (c != '\n')) -> 1

  9. ((5 && (y != 8)) || 0) -> 1

  10. ((x >= y) >= z) -> 1



Thomas P. Kelliher
Thu Feb 8 15:50:11 EST 1996
Tom Kelliher