????I need to know if I am doing this program correctly from the instruction bel
ID: 3647826 • Letter: #
Question
????I need to know if I am doing this program correctly from the instruction below.????//Write a function that dynmamically allocates an array of integers.
????//The function should accept an intergers argument indicating the number of elements to allocate.
????//The function should return a pointer to the array.
????Also I am receiving this error : Run - Time check failure # 3; The variable integer0fnumbers is being used without being initialized. Please help I have to turn this in tomorrow.
#include <iostream>
using namespace std;
int main ()
{
int *integerOfnumbers; //number to represent the integers
int size; //point to other arrays
cout << "How many elements do you have?";
cin >> *integerOfnumbers;
//Elements use to make the array
integerOfnumbers = new int [size];
// Populate number entered
for (int index = 0; index < size; index++)
{
cout << " Please enter a number:" << (index + 1)
<< " : ";
cin >> integerOfnumbers[index];
}
// Delete array when dynamically-allocate is done
delete [] integerOfnumbers;
integerOfnumbers = 0;
}
Explanation / Answer
Below is a sample function that allocates space for an array of integer and assigns values to the array int* doit(int num) { int* addr = new int[num]; for(int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.