Name: ____________________________________________________ Alpha:
_____________ Section: ________
Describe help received: _________________________________________________________________
See the bottom for how to submit your work.
Due: Before 0800 on next class day
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); }
| expression | type (or error!) | value (or error!) |
XX | N/A | |
A | N/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]) |
hw.cpp
that works like this:
v and w of that size.
<v,w> and
<w,v>.
~/$ ./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.cppBring to class