Name: ____________________________________________________ Alpha: ________________________

Describe help received: _____________________________________________________________________

See the bottom for how to submit your work.

  1. [10 pts] We would like you to self-test how much you retained from the lecture. Write the correct solution to the Practice Problem of
     Determining the state of H2O
    Debug your code until it runs correctly. Circle below how you wrote your code.
    1. (10 pts) I was able to write the code without referring to anything.
    2. (10 pts) I had to look at the notes, but still I was able to write the code without looking at the solution.
    3. (10 pts) I had to look at solutions to finish to code.
    4. (0 pts) I didn't do this.
    If you had to look at the solution, briefly describe what you missed but understand now.
    
    
    
    
  2. [3pts] With super vision you look into your computer and see that a particular byte in memory has contents 00101010. If we interpret that byte as a char, what character does it represent?
  3. [3pts] Calculate the following:

     0x3c + 0x94 =
  4. [4pts] Consider the following program and program output. Annotate the memory diagram on the right with the variables are and their values so that the digaram shows the state of memory just after the code has been executed.
    code output
    
    int p;
    int q;
    p = 5; 
    p = p + 7;
    q = p - 2;
    
    cout << &p << endl;
    cout << &q << endl;
    
    0x7ffff79351d0
    0x7ffff79351dc
    
      
    memory diagram
       address              value          (annotate variables p and q)
    0x000000000000
    ...
    0x7ffff79351c4
    0x7ffff79351c8
    0x7ffff79351cc
    0x7ffff79351d0
    0x7ffff79351d4    
    0x7ffff79351d8    
    0x7ffff79351dc            
    ...
    0xffffffffffff
    
  5. [10pts] For each of the below, circle the correctly parenthesized version of the expression and circle "precedence" or "associativity" as appropriate.

    expressionevaluated asdue to
    x + y * z (x + y) * z   OR   x + (y * z) precedence   OR   associativity
    x > y + z (x > y) + z   OR   x > (y + z) precedence   OR   associativity
    cin >> x >> y (cin >> x) >> y   OR   cin >> (x >> y) precedence   OR   associativity
    x = y = 1 (x = y) = 1   OR   x = (y = 1) precedence   OR   associativity
    x = y == z (x = y) == z   OR   x = (y==z) precedence   OR   associativity
  6. [70pts] Write a program that reads in a 3-letter word in uppercase letters and prints out the same word with lowercase letters A typical run of the program should look like (user input colored red):
    Input a 3-letter word in uppercase letters: CAT
    Output: cat
    
    Hint: You don't need to use an if-statement for this problem. Look at the ASCII table and think about how to go from the ASCII value of a uppercase letter to the ASCII value of the same letter in lowercase.

Turn in