Name: ____________________________________________________ Alpha: ________________________

Describe help received: _____________________________________________________________________

Print this homework sheet, bring it to the class, and turn it in right before the next lecture starts.

  1. [10pts] For each of the below, circle expression, statement or neither appropriately.
    1. expression / statement / neither: double x;
    2. expression / statement / neither: 3 / x
    3. expression / statement / neither: y = x*5
    4. expression / statement / neither: 4 + x /
    5. expression / statement / neither: x = 4;
  2. [24pts] Assume the following declarations fill in the table.
    double a = 20.3;
    int b;
    char c;
    b = 3;
    c = 4*a + b;
    
    expressiontypevalue
    a + b
    b / 4
    b % 4
    c
    int(c)
    b = a
  3. [4pts] What is the output of the following code?
    
    cout << (2.5*4)/5 << endl << 2.5*(4/5) << endl; 
    
  4. [2pts] 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?
  5. [60pts] 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: 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.

    Note: You MUST name your program hw.cpp. To avoid confusion, place this in a ic210/hw05 directory. This will be last time we make this point about directories and filenames, so remember it! For future homeworks, look ahead to the given "submit" command to verify what your program should be named.

    Submit

    ~/bin/submit -c=IC210 -p=hw05 hw.cpp
    
    Turn in A printout of this cover sheet and the codeprint of hw.cpp