CPSC 110-08: Computing on Mobile Phones
Spring 2012

Quiz 2 Practice Questions
Answer Key

This set of questions is about number conversions. You might want to look back at this homework and this lecture. You might also want to practice on these Khan exercises:

  1. Convert the binary value 1001 1010 to decimal. Show your work.

  2. Convert the hexadecimal value 5A to decimal. Show your work.

  3. Convert the decimal value 135 to binary. Show your work.

  4. Convert the decimal value 135 to hexadecimal. Show your work.

Instructions: The next two problems ask you to read Pseudocode or App Inventor algorithm. Trace through each of them by hand, keeping track of the variables, to determine the answer to the questions.

  1. Suppose you have a global variables named Var and N. What value would Var have after the following Pseudocode segment?
    Set Var to 100
    Set N to 3
    Set Var to Var - N
    If Var < 97 then do:
       Set Var to 0
    else-do:
       Set Var to 1
    
  2. Consider the App Inventor procedure on the right. Suppose the procedure was called 100 times. Describe as specifically as you can in 1-2 sentences what the procedure would do.



Instructions: The next problem asks you to write a Pseudocode algorithm. Model your answers after the Pseudocode algorithm in question 5.

  1. Suppose you have a variable N and a variable M. Write an if/else algorithm that tests whether N and M are equal. If they are, set the variable Var to 1. Otherwise set it to 0.








    Click here for the solutions. But no peeking until after you've tried the problems.