CPSC 120 Fall2003
Test 2 Makeup Problems

SHOW ALL WORK!!!
  1. Consider the 9-bit two's complement number 011100010.
    1. Give the base 10 value of this number.
    2. Add this two's complement number to itself and convert the result to base 10. Explain your answer.
    3. What is the largest 9-bit two's complement number you can add to itself without having this problem?
    4. What is the smallest (most negative) 9-bit two's complement number you can add to itself without having a similar problem?




















  2. Use the laws of logic to simplify the following logic statement. Show what law you are applying at each step.
           NOT(NOT p OR q) AND NOT(p AND (NOT q OR p))
    
























  3. Write code that asks the user to enter a valid password, where a valid password must have at least 6 characters and cannot be the string "Roanoke". Keep asking for passwords until the user enters one of the appropriate length, and count how many tries it takes them to get it right. When they do enter a valid password, print the number of tries it took (including the last try, where the password was valid).