Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <vector>
    using namespace std;
    int main ()
    {
    vector<int> VectorData (5);
    for (unsigned k = 0; k < VectorData.size(); k++)
    VectorData.at(k) = k;
    for (unsigned k = 0; k < VectorData.size(); k++)
    cout << ' ' << VectorData.at(k);
    return 0;
    }
    1. 0 1 2 3 4
    2. 0 1 2 3
    3. 0 1 2
    4. 0 1
Correct Option: A

In this program, We are pushing the values into the vector from 0 to 5 by using for loop.



Your comments will be displayed only after manual approval.