Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    int main ()
    {
    int Array[]={ 110, 220, 230, 440, 550 };
    vector<int> VectorData (5, 85);
    iter_swap(Array, VectorData.begin());
    iter_swap(Array + 4,VectorData.begin() + 3);
    for (vector<int> :: iterator Iter = VectorData.begin();
    Iter != VectorData.end(); ++Iter)
    cout << ' ' << *Iter;
    return 0;
    }
    1. 110 220 230
    2. 110 85 85 550 85
    3. 110 85 85
    4. 85 550 85
    5. Compilation Error
Correct Option: B

In this program, We are swapping the certain values in two vectors by using iter_swap.



Your comments will be displayed only after manual approval.