Question:
Write a code fragment that asks the user to enter a positive integer and then creates a dynamic array of that many ints. Do this by using new, then again using a vector object.Answer:
This assumes that the iostream and vector header files have been included andthat there is a using directive:
unsigned int size;
cout << "Enter a positive integer: ";
cin >> size;
int * dyn = new int [size];
vector<int> dv(size);
0 Questions:
Post a Comment