// This program uses a pointer to display the contents 
// of an integer array 
#include <iostream>
using namespace std;

int main()
{
    const int SIZE = 8;
    int numbers[SIZE] = { 5, 10, 15, 20, 25, 30, 35, 40 };
    int *ptr = numbers;         // Make ptr point to numbers
    
    // display the numbers in the array 
    cout << "The numbers are:\n";
    cout << *ptr << " ";     // Display first element
    while (ptr < &numbers[SIZE - 1])
    {
        // advance ptr to point to the next element
        ptr++;
        // display the value pointed to by ptr 
        cout << *ptr << " ";
    }
    
    // display the numbers in reverse order
    cout << "\nThe numbers backward are:\n";
    cout << *ptr << " ";     // display first element 
    while (ptr > numbers)
    {
        // move backward to the previous element
        ptr--;
        // display the value pointed to by ptr 
        cout << *ptr << " ";
    }
    return 0;
}