Operator Precedence and Associativity Worksheet

CS 116

Oct. 23, 2000

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 character representation is used.

  1. x > 9 && y != 3

  2. x == 5 || y != 3

  3. ! ( x > 14 )

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

  5. x <= 1 && y == 6 || z < 4

  6. c >= 'a' && c <= 'z'

  7. c >= 'A' || c <= 'Z'

  8. c != d && c != '\n'

  9. 5 && y != 8 || false

  10. x >= y >= z



Thomas P. Kelliher
Sun Oct 22 15:25:40 EDT 2000
Tom Kelliher