Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

  1. [10pts] Assume the following declarations and function definitions. For each expression, write the type and value. Note: "error" is a possiblity. Second note: each question is independent, i.e. no side effects of one expression should be taken to carry over to the next.
double x = 2.25;
int n = 2;
string s = "hard";
int *A = new int[3]
A[0] = 6; A[1] = 9; A[2] = 8;
string *B = new string[2];
B[0] = "hi"; B[1] = "bye";
double *X = new double[3];
X[0] = 5.1; X[1] = 5.4; X[2] = 5.7;
  --------------- --------- -------------------
  expression      type      value (or error!)

  A[1] - x             

  A[0] = X[n]          


  --------------- --------- -------------------
  1. [90Pts] Write a program that reads a number n from the user, reads an n-word sentence from the user, and then prints out the sentence in reverse (but not the words). A typical run of the program might look like this:

    ~/$ ./prog
    Number of words: 3
    Sentence: Sam I am
    am I Sam

    Use arrays not recursion! Turn In this cover sheet (obviously) and a printout of your program along with a screen capture showing it running on some clever sentence.