C++ Programming Code Examples C++ > Mathematics Code Examples Program to Generate N Number of Passwords of Length M Each Program to Generate N Number of Passwords of Length M Each This is a C++ Program to generate N passwords each of length M. This problem focuses on finding the N permutations each of length M. #include<iostream> #include<conio.h> #include<stdlib.h> using namespace std; void permute(int *a, int k, int size) { if (k == size) { for (int j = 0; j < size; j++) { cout << *(a + j); } cout << endl; } else { for (int j = k; j < size; j++) { int temp = a[k]; a[k] = a[j]; a[j] = temp; permute(a, k + 1, size); temp = a[k]; a[k] = a[j]; a[j] = temp; } } } int main(int argc, char **argv) { cout << "Enter the length of the password: "; int m; cin >> m; int a[m]; for (int j = 0; j < m; j++) { /*generates random number between 1 and 10*/ a[j] = rand() % 10; } for (int j = 0; j < m; j++) { cout << a[j] << ", "; } cout << "The Passwords are: "; permute(a, 0, m); }