{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Quiz%203_Key - ICS 313-03(021 ID Quiz 3 Name Weight 4 18...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ICS 313-03 (021) Quiz # 3 Weight 4% 18 Nov, 2002 Q. 1 [5 points]: Describe a situation in which the add operator in a programming language would not be associative. Consider the integer expression A + B + C . Suppose the values of A , B , and C are 20,000, 25,000, and -20,000, respectively. Further suppose that the machine has a maximum integer value of 32,767. If the first addition is computed first, it will result in overflow. If the second addition is done first, the whole expression can be correctly computed. Q. 2 [5 points]: 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 two expressions by parenthesizing all subexpressions and placing superscript on the right parenthesis to indicate order. a. a *(b - 1) / c mod d b. –a or c = d and e a. ( ( ( a * ( b - 1 ) 1 ) 2 / c ) 3 mod d ) 4 b. (( - a ) 1 or (( c = d ) 2 and e ) 3 ) 4 ID: ___________ Name: _____________________
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Q. 3 [5 points]: Rewrite the following code segment using a multiple selection statement in C or Java:
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}