Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
     #include <iostream>
    using namespace std;
    int arr[10] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
    void swap(int p, int q)
    {
    int temp = arr[p];
    arr[p] = arr[q];
    arr[q] = temp;
    return;
    }
    void printArr(int size)
    {
    int k;
    for (k = 0; k < size; k++)
    cout << arr[k] << " ";
    cout << endl;
    return;
    }
    void Permutation(int n, int size)
    {
    int k;
    if (n == 0)
    printArr(size);
    else
    {
    for (k = n - 1; k >= 0; k--)
    {
    swap(k, n - 1);
    Permutation(n - 1, size);
    swap(k, n - 1);
    }
    }
    return;
    }
    int main()
    {
    Permutation(3, 4);
    return 0;
    }
    1. 10 11 12 13
      11 10 12 13
    2. 10 12 11 13
      12 10 11 13
    3. 12 11 10 13
      11 12 10 13
    4. All of above
    5. None of these
Correct Option: D

In this program, We are finding the permutation without using the permutation function.



Your comments will be displayed only after manual approval.