PLEASE HELP WRITE THE CODE IN C LANGUAGE . I REALLY APPRECIATE YOUR HELP AND PLE
ID: 3597929 • Letter: P
Question
PLEASE HELP WRITE THE CODE IN C LANGUAGE. I REALLY APPRECIATE YOUR HELP AND PLEASE COMMENT
Intro to C- Assignment - Password Generator Your program must Ask the user if they wish to generate a word-based password or a character-based one . If they request a character-based password o Ask for how many random letters to include o Ask for how many random digits to include o Generate a password from the requested characters and display it to the user Randomly decide between upper and lower case letters . If they request a word-based password o Ask for how long to make the password o Choose words from a list you've created of at least 10 o Concatenate random words from the list to the password being created until you have reached or exceeded the requested length Randomly capitalize some of the letters In either case, vou must store the password as a string before outputting it o This means you will need to limit the requested password length to the size of your variable! 5% of the grade will be removed for each day the assignment is late (up to 30%). If you have extenuating circumstances and need an extension, please contact me before the due date Please include the honor code with your submission Extra Credit (10%) Randomize the order of the letters and digits in the character-based password . Creating an Array of Strings There are two ways to create a list of strings examp lewords[] {"add", "cap", "dance", "miles", "pets"); char * char exampleWords2[5][10] { "add", "cap", "dance", "miles", "pets"); The difference in functionality is that the second way is creating an array of 5 strings with the ability to hold 10 characters each, while the first does not have any extra room (this may be useful in the future, even if it is not needed for this assignment) Example Input and Output elcome to the Password Generator! lelcome to the Password Generator! enu enu 1 Random Characters Password 2 Random Words Password 1- Random Characters Password 2 Random Words Password Your choice: 1 How many letters to include?6 How many digits to include?4 Your password is RaYioU7675 Press any key to continue . Your choice: 2 How many characters?12 Your password is laptOpsitEUser Press any key to continue . . . You do not need to match this input and output exactly, but they're a guide for what you would want to aim forExplanation / Answer
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
int main() {
int x,y,z,p,q,r,j=0,t;
char a[100],b[2],c[2],d[2],k;
char m[5][10]={"hello","laptop","good","hi","key"};
printf("Welcome to the Password Generator!");
printf(" Menu");
printf(" 1 - Random Characters Password");
printf(" 2 - Random Words Password");
printf(" Your Choice");
scanf("%d",&x);/* accept choice */
if(x==1)
{
printf("how many letters to include?");
scanf("%d",&y);/* to accept number of letters */
printf(" how many digits to include?");
scanf("%d",&z);/* to accept number of digits */
if(y%2==0)/*to check whether y is even or odd */
{
for(r=1;r<=y;)
{
p=rand()%26;/* random letter ascii value*/
b[0]='A'+p; /* coverting the ascii into upper case letter */
p=rand()%26;
c[0]='a'+p;/* coverting the ascii into lower case letter */
strcat(a,b);/* concatenation of a,b*/
strcat(a,c);/* concatenation of a,c*/
r=r+2; /*increment the generated letters count */
}
}else{
y--;
for(r=1;r<=y;)
{
p=rand()%26;/* random letter ascii value*/
b[0]='A'+p; /* coverting the ascii into upper case letter */
p=rand()%26;
c[0]='a'+p;/* coverting the ascii into lower case letter */
strcat(a,b);/* concatenation of a,b*/
strcat(a,c);/* concatenation of a,c*/
r=r+2; /*increment the generated letters count */
}
p=rand()%26;
c[0]='a'+p;/* coverting the ascii into lower case letter */
strcat(a,c);/* concatenation of a,c*/
}
for(r=0;r<z;r++)
{
p=rand()%10;
b[0]='0'+p;
strcat(a,b);
}
}else if(x==2)
{
printf("how many Characters?");
scanf("%d",&y);
for(r=0;r<y;)
{
p=rand()%5;/* selecting the index for random word */
j=0;
while(j<strlen(m[p]))/* until the end of the selected random word from list */
{
z= rand()%2;/*random number for making a letter upper or lower */
if(z==1)/*if z=1 we make a letter as upper */
{
/*for uppers letters in password */
k=m[p][j];
j++;
a[r]=toupper(k);
r++;/*increment the overal size of the password generated */
}
else{
/*for lower letters in password */
a[r]=m[p][j];
j++;
r++;/*increment the overal size of the password generated */
}
if(r==y)/* if required password length reached then break from the loop */
break;
}
}
}
printf(" Your Password is:%s",a);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.