adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <vector>
    using namespace std;
    int main ()
    {
        vector<int> myvector (5);
        int* p = myvector.data();
        *p = 10;
        ++p;
        *p = 20;
        p[2] = 100;
        for (unsigned i = 0; i < myvector.size(); ++i)
            cout << ' ' << myvector[i];
        return 0;
    }

a.

10 20 0 100 0

b.

10 20 0 100

c.

10 20 0

d.

10 20

Answer: (a).10 20 0 100 0

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?