Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
int n = 2;
string s = "hard";
double x = 2.25;
int* A = new int[3];
string* B = new string[2];
double* X = new double[3];
A[0] = 6; A[1] = 9; A[2] = 8;
B[0] = "hi"; B[1] = "bye";
X[0] = 5.1; X[1] = 5.4; X[2] = 5.7;
double sqr(double z) { return z*z; }
bool isneg(int k) { return (k < 0); }
| expression | type (or error!) | value (or error!) |
X | N/A | |
A | N/A | |
X[0] | ||
A[1] - x | ||
A[0] = X[n] | ||
++A[2] | ||
B[1] | ||
A[1] + X[1] | ||
sqr(A[0]) | ||
sqr(X[0]) | ||
isneg(X[0]) |
hw.cpp that reads a number n from
the user, reads an n-word sentence from the user, and then prints
out the sentence forwards, followed by a question mark, then reversed,
followed by an exclamation mark (but do not reverse the letters within the
words). A typical run of the program might look like this:
$ ./hw Number of words: 3 Sentence: am I Sam am I Sam? Sam I am! $ ./hw Number of words: 4 Sentence: places you drive cars places you drive cars? cars drive you places!
Use arrays!
~/bin/submit -c=IC210 -p=hw17 hw.cpp