CS 630 - Computing Fundamentals I - Summer 2004
Homework 7


Loyola College > Department of Computer Science > CS 630 > Homework > Homework 7

Due

Wednesday, July 21st at the beginning of class
Email programs (.cpp files) to lawrie@cs.loyola.edu

Problems

Problem 1: 5.9

Problem 2: 5.10

Problem 3: 5.23 a, c, f

Problem 4: Draw a trace of the following program beginning on line 6. What is the output?

int main() {
   int x = 3;
   int y = 5;
   int z = 7;
   int *ptr1, *ptr2;

   ptr1 = ptr2 = &x;   // Begin trace here
   x = 2;
   ptr1 = &z;
   *ptr1 = 4;
   *ptr2 = 6;
   ptr2 = &y;
   *ptr2 = *ptr1;
   z = 10;

   cout << x << " " << y << " " << z << " " << *ptr1 << " " << *ptr2 << endl;

   return 0;
}