/* Filename: bad.cpp Author: Br. David Carlson Date: January 12, 1998 Revised: June 27, 2000; August 17, 2001 This program prompts the user to enter integers into an array, where they are stored in backwards order from that in which they are entered. The list of numbers is then printed on the screen (in backwards order, of course, from the order in which they were entered). Tested with: Microsoft Visual C++ 6.0 Microsoft Visual C++ .NET g++ under Linux */ #include using namespace std; const int MAX = 6; int count; void LoadArray(int a[]) void PrintArray(int a[]) int main(void) { int num[MAX]; count = MAX; LoadArray(num); PrintArray(num); return 0; } /* Given: Task: Return: */ void LoadArray(int a[]) { for (count = MAX - 1; count >= 0; count--) { cout << "Enter an integer: " ; cin >> a[count]; } } /* Given: Task: Return: */ void PrintArray(int a[]) { int m; cout << "The data in the array at the indices shown in the left column is:" << endl; for (m = 0; m < count; m++) cout << m << ": " << a[m] << endl; }