#include using namespace std; int get_numbers(int [], int, int); const int MAX_SIZE=4; /* * Store numbers in the array. * * array - array to store the numbers in. * size - the size of the array. * at - the position to start storing numbers at. * * Returns next free position in the array. */ int get_numbers(int array[], int size, int at){ int temp; // Range check for at. // If at is invalid, abort the program. if(at>=size || at<0){ cerr << "Invalid array storage position!" << endl; exit(-1); } do { cerr << "Enter in a number (-1 to indicate done): "; cin >> temp; // If number is valid, store it. if(temp>=0) { array[at]=temp; // Go to the next free position. at++; } }while(at=0); return at; } int main() { int a[MAX_SIZE]; // Position to store at. int position=0; // Last position in the array. int last; last=get_numbers(a,MAX_SIZE,position); for(int i=0;i