{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Midterm05Solved

# Midterm05Solved - Solution to Midterm 2005 Question 1a The...

This preview shows pages 1–5. Sign up to view the full content.

1 Solution to Midterm 2005 Question 1a) The integer X has the value 5, and the array Y initially contains the following values: {2, 4, 6, 8, 10}. Only one of the following Boolean expressions evaluates to true. Circle the letter corresponding to the expression that evaluates to true. a) (X < 5) OR (Y[Y[1]] = 8) b) (Y[4] ÷ 2 = X) AND (X MOD 2 = Y[1] MOD 2) c) (X > Y[2]) AND (X Y[3]) d) Y[Y[0]] × 2 = (2 × X + X MOD 3) e) X × X Y[1] × Y[2]

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

View Full Document
2 Question 1a) The integer X has the value 5, and the array Y initially contains the following values: {2, 4, 6, 8, 10}. Only one of the following Boolean expressions evaluates to true. Circle the letter corresponding to the expression that evaluates to true. a) (X < 5) OR (Y[Y[1]] = 8) F OR Y[4] = 8 F OR 10 = 8 F OR F F Question 1a) The integer X has the value 5, and the array Y initially contains the following values: {2, 4, 6, 8, 10}. Only one of the following Boolean expressions evaluates to true. Circle the letter corresponding to the expression that evaluates to true. b) (Y[4] ÷ 2 = X) AND (X MOD 2 = Y[1] MOD 2) 10 ÷ 2 = 5 AND ( 5 MOD 2 = 4 MOD 2 ) 5 = 5 AND ( 1 = 0 ) T AND F F
3 Question 1a) The integer X has the value 5, and the array Y initially contains the following values: {2, 4, 6, 8, 10}. Only one of the following Boolean expressions evaluates to true. Circle the letter corresponding to the expression that evaluates to true. c) (X > Y[2]) AND (X Y[3]) 5 > 6 AND 5 8 F AND T F Question 1a) The integer X has the value 5, and the array Y initially contains the following values: {2, 4, 6, 8, 10}. Only one of the following Boolean expressions evaluates to true. Circle the letter corresponding to the expression that evaluates to true. d) Y[Y[0]] × 2 = (2 × X + X MOD 3) Y[2] × 2 = (2 × 5 + 5 MOD 3) 6 × 2 = (10 + 2) 12 = 12 T

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

View Full Document