// recprint.cpp  - It prints out the elements of an array. It uses recursion!

#include <iostream>

// It prints out the first n elements of a.
void recprint(int a[], int n)
{
   if (n>0)
   {
      cout << '\t' << a[0];
      recprint(a+1, n-1); // Notice pointer arithmetic: a+1 is the address
                          // of the second element in a
   }
}

// It prints out the first n elements of a
// in reverse order.
void recrprint(int a[], int n)
{
   if (n>0)
   {
      cout << '\t' << a[n-1];
      recprint(a, n-1);
   }
}

void main(void)
{
   int table[] = { 7,6,2,3,4};

   recprint(table, 5);
   cout << endl;
   recrprint(table, 5);
   cout << endl;

}

