Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int main ()
    {
    int Numbers[] = {23, 25, 32, 43};
    sort (Numbers, Numbers + 4);
    do
    {
    } while ( next_permutation(Numbers, Numbers + 4) );
    cout << Numbers[0] << ' ' << Numbers[1] << ' ' << Numbers[2] << ' ' << Numbers[3] << '\n';
    return 0;
    }
    1. Compilation Error
    2. 23
    3. 23 25
    4. 23 25 32
    5. 23 25 32 43
Correct Option: E

In this program, We are doing the permutation in the do while loop and then printing last permuted value.



Your comments will be displayed only after manual approval.