#include <stdio.h>

int main()
{
  int x=2, y=3, temp;
  int *ptr1, *ptr2, *ptr3;

  // make ptr1 point to x
  ptr1 = &x;

  // make ptr2 point to y
  ptr2 = &y; 

  // print values pointed by ptr1 and ptr2
  printf("Out1: ptr1 points to %d\n",*ptr1);
  printf("Out1: ptr2 points to %d\n\n",*ptr2);

  x = 4;

  // print values pointed by ptr1 and ptr2
  printf("Out2: ptr1 points to %d\n",*ptr1);
  printf("Out2: ptr2 points to %d\n\n",*ptr2);

  // swap the contents of ptr1 and ptr2
  ptr3 = ptr1;
  ptr1 = ptr2;
  ptr2 = ptr3;

  // print values pointed by ptr1 and ptr2
  printf("Out3: ptr1 points to %d\n",*ptr1);
  printf("Out3: ptr2 points to %d\n\n",*ptr2);

  // swap the values pointed by ptr1 and ptr2
  temp = *ptr1;
  *ptr1 = *ptr2;
  *ptr2 = temp;

  // print values pointed by ptr1 and ptr2
  printf("Out4: ptr1 points to %d\n",*ptr1);
  printf("Out4: ptr2 points to %d\n\n",*ptr2);

  //  system("pause");
  return(0);
}
