Starting from:

$40

ENGG1340 Computer Programming II Module 8 Self-Review Exercise Solution Solved

ENGG1340 Computer Programming II 
Module 8 Self-Review Exercise Solution 

      int x; 

      int * ptr1, * ptr2;       double * ptr3; 

 

 int x;  int y;  int * p = &x;  p = &y;  *p = 10;  x = y + 20;  p = &x;  y = 25;  *p = 50; 

 cout << *p << " " << x << " " << y << endl; 

 

 int *x = new int;  int *y;  *x = 60;  y = x;  *y = *y + *x;  x = new int;  *x = *y - 20;  cout << *x << " " << *y << endl; 

       

 double *x = new double;  double *y = new double;  *x = 10;  y = x;  delete x;  delete y;  x = new double;  *x = 20; 

 cout << *x << " " << *y << endl; 

  


 int * aPtr;          // aPtr should point to array a  int n; 

 int a[5] = { 1, 2, 3, 4, 5 }; 

 

 // use pointer to get the first value of array // assign 2nd element of array to n

      for (int i = 0; i <= 5; ++i)           cout << aPtr[i] << endl;

                 ++a;

 

 

int array[7] = { 4, 8, 9, 1, 13, 32, 20}; 

 int * ptr = array;  *ptr = *ptr + 5;  ptr = ptr + 2; 

 *ptr = (*ptr) - *(ptr - 1);  ptr++; 

 *ptr = 5 * (*ptr) - 2; 

 

 

 

 

 

 

   int info; 

         Node * next; 

      }; 

 

      head current temp trail last           Node * 

Use the above list to answer questions 1 to 5. 

 

 

 

 

 

  

 

 

       
   temp = current;                 // Line 1 

            current = current-next;        // Line 2 

            current-next = last;           // Line 3 

            trail = current- next;         // Line 4 

            trail = trail-next;            // Line 5 

            cout << current-info << " " << trail-info << endl;       // Line 6 

More products