# COSC 450 hw1

1. Assume the following rules of associativity and precedence for expression:

Precedence Highest *, /, not

+, -, &, mod

-(unary)

=, /=, <. <=, =,

and

Lowest or, xor

Associativity Left to right

Show the order of evaluation of the following expressions by parenthesizing all

subexpressions and placing a superscript on the right parenthesis to indicate order. For

example, for the expression

a + b * c + d

the order of evaluation would be represented as

((a + (b * c)1)2 + d)3

a. a * b – 1 + c

b. a * (b – 1) / c mod d

c. (a – b) / c & (d * e / a – 3)

d. –a or c = d and e

e. a b xor c or d <= 17

f. –a + b

2. Show the order of evaluation of the expressions of the above expressions, assuming that

there are no precedence rules and all operators associate right to left.

Precedence Highest *, /, not

+, -, &, mod

-(unary)

=, /=, <. <=, =,

and

Lowest or, xor

Associativity Left to right

Show the order of evaluation of the following expressions by parenthesizing all

subexpressions and placing a superscript on the right parenthesis to indicate order. For

example, for the expression

a + b * c + d

the order of evaluation would be represented as

((a + (b * c)1)2 + d)3

a. a * b – 1 + c

b. a * (b – 1) / c mod d

c. (a – b) / c & (d * e / a – 3)

d. –a or c = d and e

e. a b xor c or d <= 17

f. –a + b

2. Show the order of evaluation of the expressions of the above expressions, assuming that

there are no precedence rules and all operators associate right to left.

You'll get 1 file (17.5KB)