/**************************************************************/
// R. A. Hillyard
// pointer01.cpp
// November 2001
//
// Program to demonstrate the basic use of pointers
/**************************************************************/
#include<iostream>
#include<iomanip>

using namespace std;

int main()
  {
  int *intPtr1, *intPtr2, a = 25, b = 55;  //declare 2 int pointers and two ints

  intPtr1 = &a;  //assign intPtr1 to point at a
  intPtr2 = &b;  //assign intPtr2 to point at b

  //print out initial values
  cout << "variable values: " << a << " " << b <<  endl;
  cout << "intPtrs values:  " << *intPtr1 << " " << *intPtr2  <<  endl;
 
  //update value of a 
  a = *intPtr2;
  cout << "after update a = " << a << " b = " << b <<  endl;

  //update the value of a through pointer 
  *intPtr1 = b + 15;
  cout << "after update a = " << a << " b = " << b <<  endl;

  *intPtr2 = *intPtr1 * 2;
  cout << "after update a = " << a << " b = " << b <<  endl;
  return 0;
  }
/***********************Program Output*************************/
variable values: 25 55
intPtrs values:  25 55
after update a = 55 b = 55
after update a = 70 b = 55
after update a = 70 b = 140
/**************************************************************/