previous | start | next

8. Pointer Example 2

Write a function to swap two integers if the parameters passed to the function are pointers to the two integers.

int main()
{
  int x = 5;
  int y = 10;

  swap(&x, &y);
  cout << "x = " << x << endl;
  cout << "y = " << y << endl;

  return 0;
}

void swap(int *p, int *q)
{
 
}

         


previous | start | next