-
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;
}
-
- 10 11 12 13
11 10 12 13 - 10 12 11 13
12 10 11 13 - 12 11 10 13
11 12 10 13 - All of above
- None of these
- 10 11 12 13
Correct Option: D
In this program, We are finding the permutation without using the permutation function.