// Add two matrices using pointers
#include <iostream>
using namespace std;

int main ()
{
  int A[5], B[5];
  int i;
  int *ptr_A, *ptr_B;
  
  for (i=0; i<5; i++)
  {
       A[i] = 2*i+1;
       B[i] = i*i;
  }

  for (i=0; i<5; i++)
  {
  	cout << "A[" << i << "] + ";
  	cout << "B[" << i << "] = ";
     cout << A[i] << " + " << B[i] << " = " << A[i]+B[i] << endl;
  }

  ptr_A = A;
  ptr_B = B;

  cout << endl << endl;

  cout << "Using pointers\n";
  for (i=0; i<5; i++)
  {
  	cout << "A[" << i << "] + ";
  	cout << "B[" << i << "] = ";
     cout << A[i] << " + " << B[i] << " = " << *ptr_A + *ptr_B << endl;

     ptr_A++;
     ptr_B++;
  }

 cout << endl << endl; 

  return 0;
}

