1. (->*& and all that) based on problem 2.17 in Ford and Topp
For the following code segment, show the values of x, y, *p, *q at the five places indicated.
int x = 5; int y = 7; int *p = &x; int *q = &y; // 1a. x, y, *p, *q (*p)--; // 1b. x, y, *p, *q *q += *p; // 1c. x, y, *p, *q q = p; // 1d. x, y, *p, *q *q = 55; // 1e. x, y, *p, *q
2. (arrays and pointers ) also based on problem 2.17 in Ford and Topp
For the following code segment, show the values of *Dptr and the contents of the array D[] at the six places indicated.
double D[] = {3.1, 5.2, 4.4, 0.1, -5.0, 0.0, 9.8};
double* Dptr = D;
// 2a. contents of D[]; value of *Dptr
*Dptr += 7.7;
// 2b. contents of D[]; value of *Dptr
Dptr++;
// 2c. contents of D[]; value of *Dptr
*Dptr++ = 9.9;
// 2d. contents of D[]; value of *Dptr
Dptr +=2;
// 2e. contents of D[]; value of *Dptr
*++Dptr = 8.8;
// 2f. contents of D[]; value of *Dptr
3. (a bit of binary)
a. Compute the decimal value of each of the following binary numbers
5. Write the declarations only for a class DynamicSet that has objects of template class T. The first programming assignment - to be started in lab Tuesday April 8, will involve implementing and using this class.
Include pre- and post- conditions in your member function declarations!
Cormen, Leiserson, & Rivest in "Introduction to Algorithms", McGraw Hill & MIT Press, 1990, page 197 define a Dynamic Set a collection of objects whose fields can be manipulated if we have a pointer to the object. There are two types of operations that can be performed on a Dynamic Set S:
Queries:
Last Updated: April 6, 1997 11:48 am by