Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I dynamically expand my array? Here is the code I have now.. After this f

ID: 3595135 • Letter: H

Question

How do I dynamically expand my array? Here is the code I have now.. After this function runs, I want to prompt the user how many numbers theyd like to append to the array, and then they will be prompted each number with the same process below.. (C++)

void myArray::arrayNums(int *point, int size, int temp)

{

   cout << "Amount of numbers you would like in your array: ";

   cin >> size;

   cout << " ";

   int *pointer = NULL;

   point = new int[size];

   for (int counter = 0; counter < size; counter++)

   {

       cout << "Enter your number " << counter + 1 << ": ";

       cin >> temp;

       *(point + counter) = temp;

   }

   cout << " Here is your array: " << endl;

   for (int counter = 0; counter < size; counter++)

   {

       cout << "arr[" << counter << "] = " << *(point + counter) << endl;

   }

}

Explanation / Answer

Or You can use a dynamic container such as vectors.

Please do give a thumbs up and leave a nice comment too.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote