1. ## UIL Programming Question

I recently competed in a UIL (University Interscholastic League) competition in computer science. During the test, I came upon a question that had me stumped. Later on, I showed a copy of the test to my computer science teacher, who could not explain it either. If you would like a shot at this, here it is. Oh, and if you can do it, please leave an explanation on how/why also. Thanks ahead.

Which of the following will compute the minimum of x and y for all possible integer values x and y?
--------------------------
I. (x < y) ? x : y
II. x & y
III. (y > x) ? y : x
--------------------------

A. I only
B. II only
C. III only
D. I and III
E. I, II, and III

If you would like the answer, here it is (encrypted so you don't "accidently" see it ;-)).......take the last letter of the current president's last name and subtract from it 8 letters (ie: 'g' - 2 would be 'e'). Good luck! 2. > take the last letter of the current president's last name and subtract from it 8 letters

0? Z?
H = 8 3. I would think either I or III, though... I could be wrong. 4. well its A
The ? operator does a quick if else....

bool lvalue=(expression) ? true:false;

same as
if(expression)
bool lvalue=true;
else
bool lvalue=false; 5. So, for III to be true, it'd have to be

(y>x)?x:y

??? 6. a) if x is less than y then return x otherwise return y

b) use bitwise AND to combine x and y into a third value

c) if y is larger than x then return y otherwise return x

Therefore I choose a. 7. I'll go with A also. 8. ok, sorry....subtract 7......yes, the answer was A. Thanks for the help. Maybe _this_ time i can get first place instead of 2nd. 2nd = 1st loser Popular pages Recent additions 