Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <string>
    using namespace std;
    void PermutationString( string& orig, string& Permutation )
    {
    if (orig.empty())
    {
    cout << Permutation << endl;
    return;
    }
    for (int k = 0; k < orig.size(); ++k)
    {
    string orig2 = orig;
    orig2.erase(k, 1);
    string Permutation2 = Permutation;
    Permutation2 += orig.at(k);
    PermutationString(orig2, Permutation2);
    }
    }
    int main()
    {
    string orig = "Sumi";
    string Permutation;
    PermutationString(orig, Permutation);
    return 0;
    }
    1. Sumi
    2. imus
    3. suim
    4. returns all the combination of Sumi
    5. None of these
Correct Option: D

In the program, We used string permutation to find out all the combination.



Your comments will be displayed only after manual approval.