Please send questions to st10@humboldt.edu .

#include <iostream>   
using namespace std;

// Contract: fillArray2 : &double[] &int -> void
// Purpose: ask the user how big of an array of double
//          that he/she wants, then set arrToFill to
//          point to that array and ask the user for
//          that many values, to fill it. Also, set 
//          desiredSize to be the size of the new array 
//          (the size the user entered)
// 
// by: Sharon M. Tuttle
// last modified: 11-12-03

// I need the address of a pointer --- so I can set 
//    that pointer to point to a newly-allocated array
void fillArray2 (double* &arrToFill, int &desiredSize)
{
    // how big does the user want?
    cout << "How many elements? ";
    cin >> desiredSize;

    while (desiredSize < 0)
    {
        cout << "enter a NON-NEGATIVE size!: ";
        cin >> desiredSize;
    }

    arrToFill = new double[desiredSize];

    // fill the array with values from the user...
    for (int i=0; i < desiredSize; i++)
    {
        cout << "Enter element #" << (i+1) << ": ";
        cin >> arrToFill[i];
    }
}