-
What is the output of this program?
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> VectorData (6);
int* ptr = VectorData.data();
*ptr = 30;
++ptr;
*ptr = 15;
ptr[2] = 150;
for (unsigned k = 0; k < VectorData.size(); ++k)
cout << ' ' << VectorData[k];
return 0;
}
-
- 30 15 0 150 0 0
- 30 15 0 150 0
- 30 15 0 150
- 30 15 0
- 30 15
Correct Option: A
In this program, We are allocating the values to the vector and unallocated values are left as zero.