// This program uses a pointer to display the contents of an array. #include using namespace std; int main() { const int SIZE = 8; int set[ ] = {5, 10, 15, 20, 25, 30, 35, 40}; int *numPtr; // Pointer int index; // Used as loop index // Make numPtr point to the set array. numPtr = set; // Use the pointer to display the array elements. cout << "The numbers in set are:\n"; for (index = 0; index < SIZE; index++) { cout << *numPtr << " "; numPtr++; } cout << endl; // Display the array elements in reverse order. cout << "\nThe numbers in set backwards are:\n"; for (index = 0; index < SIZE; index++) { numPtr--; cout << *numPtr << " "; } cout << endl; return 0; }