// compile with: g++ hello.cpp #include<iostream> using namespace std; int main(int argc, char * argv[]) { int n; cout << "Number of ints: "; cin >> n; // instead of malloc, less typing and also does type-checking for us // in c: int *nums = (int *) malloc(sizeof(int) * n); int *nums = new int[n]; for(int i=0; i < n; i++) cin >> nums[i]; cout << "In reverse order..." << endl; for(int i=n-1; i>= 0; i--) cout << nums[i] << endl; // instead of free delete[] nums; return 0; }