Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
     #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
    void Result(const vector<int>& VectorData)
    {
    for (size_t k = 0; k < VectorData.size(); ++k)
    {
    cout << VectorData[k] << ' ';
    }
    }
    int main()
    {
    vector<int> VectorData;
    VectorData.push_back(4);
    VectorData.push_back(8);
    sort(VectorData.begin(), VectorData.end());
    Result(VectorData);
    while(next_permutation(VectorData.begin(), VectorData.end()))
    Result(VectorData);
    return 0;
    }
    1. Compilation Error
    2. 4 8 8 4
    3. 4 8 8
    4. 4 8
    5. 4
Correct Option: B

In this program, We find out the permutation of two numbers by using sort.



Your comments will be displayed only after manual approval.