How can I declare the function to ask the user for theirusername first, validate
ID: 3615663 • Letter: H
Question
How can I declare the function to ask the user for theirusername first, validate their username then do the same for thepassword? Thanks! The code is below...Please makechanges...#include <stdio.h>
#include<conio.h>
#include<string.h>
int main()
{char user[3][8]={"CRobert","JMoorey","BChance"};
char pw[3][8]={"spear","bluey","visor"};
char word[8];
int i=0,yes=0,j;
for(i=0;i<3;i++)
{j=0;
yes=0;
do{
printf("%s Enter your password: ",user[i]);
scanf("%s",&word);
if(strcmp(word,pw[i])==0)
yes=1;
j++;
if(yes==0&&j!=2)
printf("ERROR, INCORRECTPASSWORD. PLEASE TRY AGAIN! ");
}while(j<2&&yes==0);
if(yes==0)
printf("INCORRECT PASSWORD. GOODBYE! ");
else
printf("WELCOME! ");
}
getch();
return 0;
}
How can I declare the function to ask the user for theirusername first, validate their username then do the same for thepassword? Thanks! The code is below...Please makechanges...
#include <stdio.h>
#include<conio.h>
#include<string.h>
int main()
{char user[3][8]={"CRobert","JMoorey","BChance"};
char pw[3][8]={"spear","bluey","visor"};
char word[8];
int i=0,yes=0,j;
for(i=0;i<3;i++)
{j=0;
yes=0;
do{
printf("%s Enter your password: ",user[i]);
scanf("%s",&word);
if(strcmp(word,pw[i])==0)
yes=1;
j++;
if(yes==0&&j!=2)
printf("ERROR, INCORRECTPASSWORD. PLEASE TRY AGAIN! ");
}while(j<2&&yes==0);
if(yes==0)
printf("INCORRECT PASSWORD. GOODBYE! ");
else
printf("WELCOME! ");
}
getch();
return 0;
}
Explanation / Answer
please rate - thanks #include #include #include int validate(char[8],char[]); int main() {char user[3][8]={"CRobert","JMoorey","BChance"}; char pw[3][8]={"spear","bluey","visor"}; int i=0,yes=0,j; for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.