Skip to content

Instantly share code, notes, and snippets.

@Parassharmaa
Last active November 14, 2016 04:41
Show Gist options
  • Save Parassharmaa/576d58712aece382b0c207bb92f5e4c0 to your computer and use it in GitHub Desktop.
Save Parassharmaa/576d58712aece382b0c207bb92f5e4c0 to your computer and use it in GitHub Desktop.
Cpp program to generate random password
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
char rand_char();
int main() {
srand((int) time(0));
int n;
cout<<"Enter length of password:";
cin>>n;
for (int i=0;i<5;i++) {
for (int j=0; j<n;j++) {
cout<<rand_char();
}
cout<<endl;
}
return 0;
}
char rand_char() {
return(char(rand()%(122-97)+97));
}
@Parassharmaa
Copy link
Author

Yup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment