Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
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;
double sqr(double z) { return z*z; }
bool absme(int& k)
{
if (k < 0)
{
k = -k;
return true;
}
return false;
}
| expression | type (or error!) | value (or error!) |
X[0] | ||
A[1] - x | ||
A[0] = X[n] | ||
++A[2] | ||
B[1][0] | ||
A[1] + X[1] | ||
sqr(A[0]) | ||
sqr(X[0]) | ||
absme(A[0]) | ||
absme(X[0]) |
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 SamUse 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.