Name: ____________________________________________________ Alpha: _____________ Section: ________

Describe help received: _________________________________________________________________

See the bottom for how to submit your work.

Due: Before 0800 on next class day

  1. (10 pts) Read today's lecture notes. Honestly declare how you read the notes.
    1. (10 pts) I read the notes carefully. I have a good understanding of the topics therein.
    2. (10 pts) I read the notes carefully, but I don't really understand the following points well:
      
      
      
      
    3. (0 pts) I didn't read the notes carefully.
  2. [20pts] Assume the following delcarations and function definitions fill in the table. Note: "error" is a possiblity! Note: each question is independent, i.e. no side effects of one expression should be taken to carry over to the next.
    Tip: If necessary, write a code and test it!

    
    int n = 2;
    string s = "hard";
    double x = 2.25;
    
    int* A = new int[3];
    string* B = new string[2];
    double* XX = new double[3];
    
    A[0] = 6; A[1] = 9; A[2] = 8;
    B[0] = "hi"; B[1] = "bye";
    XX[0] = 5.1; XX[1] = 5.4; XX[2] = 5.7;
    
    double sqr(double z) { return z*z; }  
    
    bool isneg(int k) { return (k < 0); }
    

    expressiontype (or error!)value (or error!)
    XXN/A
    AN/A
    XX[0]
    A[1] - x
    A[0] = XX[n]
    ++A[2]
    B[1]
    A[1] + XX[1]
    sqr(A[0])
    sqr(XX[0])
    isneg(XX[0])
  1. [70pts] Write a program hw.cpp that works like this:

    ~/$ ./hw
    N = 3 
    X = [1.1, 2.2, 3.3]
    Y = [1, -1, 0.1]
    <X,Y> = 1.1 * 1 + 2.2 * (-1) + 3.3 * 0.1 = -0.77
    <Y,X> = 1 * 1.1 + (-1) * 2.2 + 0.1 * 3.3 = -0.77
    
    ~/$ ./hw
    N = 1
    A = [-1.2]
    B = [-4.3]
    <A,B> = (-1.2) * (-4.3) = 5.16
    <B,A> = (-4.3) * (-1.2) = 5.16
    

Submit to the submission server (due: 0800 on the next class day)

 ~/bin/submit -c=IC210 -p=hw19 hw.cpp 
Bring to class