Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <iterator>
    #include <vector>
    using namespace std;
    int main ()
    {
    vector<int> NewVector;
    for (int k = 1; k < 6; ++k)
    NewVector.push_back(k * 10);
    ostream_iterator<int> out_it (cout,", ");
    copy ( NewVector.begin(), NewVector.end(), out_it );
    return 0;
    }
    1. 10,
    2. 10, 20,
    3. 10, 20, 30,
    4. 10, 20, 30, 40,
    5. 10, 20, 30, 40, 50,
Correct Option: E

In this program, We are producing the values by vector and printing it by using ostream iterator.



Your comments will be displayed only after manual approval.