#include using namespace std; int main(int argc, char* argv[]) { int requestedSize; int counter; int* positionPointer; int* theArray; cout << "What size array would you like? " << endl; cin >> requestedSize; theArray = new int[requestedSize]; for (counter = 0; counter < requestedSize; counter++) { theArray[counter] = counter; } // traverse four ways cout << "First traversal: " << endl; for (counter = 0; counter < requestedSize; counter++) { cout << theArray[counter] << " "; } cout << endl; cout << "Second traversal: " << endl; for (counter = 0; counter < requestedSize; counter++) { cout << *(theArray + counter) << " "; } cout << endl; cout << "Third traversal: " << endl; positionPointer = theArray; for (counter = 0; counter < requestedSize; counter++) { cout << *positionPointer << " "; positionPointer = positionPointer + 1; } cout << endl; // you don't actually want to use the technique below // because it moves the pointer to the base of the // array to another location! cout << "Fourth traversal: " << endl; for (counter = 0; counter < requestedSize; counter++) { cout << *theArray << " "; theArray++; // equivalent to theArray = theArray + 1; } cout << endl; }