UIL Programming Question

This is a discussion on UIL Programming Question within the C++ Programming forums, part of the General Programming Boards category; I recently competed in a UIL (University Interscholastic League) competition in computer science. During the test, I came upon a ...

  1. #1
    araknid
    Guest

    Question 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. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    > take the last letter of the current president's last name and subtract from it 8 letters

    0? Z?
    H = 8

  3. #3
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    I would think either I or III, though... I could be wrong.

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    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;
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    So, for III to be true, it'd have to be

    (y>x)?x:y

    ???

  6. #6
    Unregistered
    Guest
    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. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    I'll go with A also.

  8. #8
    araknid
    Guest
    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 subscribe to a feed

Similar Threads

  1. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 06:51 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 01:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21