G) l the following function returns whether a pwd is correct or not // to be cor
ID: 3910030 • Letter: G
Question
G) l the following function returns whether a pwd is correct or not // to be correct it must have at least one uppercase letter // one lowercase character, one special character, one number and it must also be minSize nd it must also be minsi // Is ValidPassword"AbCal14) true Is ValidPassword" AbCdl!" 10)false (password not long enough) Is ValidPassword AbCdl"4) false (missing special character) I have coded the upper case check for you already bool Is ValidPassword(char pswd[), int minSize) char uChars[] = "ABCDEFG HIJ KLM NoPQRSTUVWXYz"; char lChars[] = "abcdefghijklmnopqrstuvwxyz"; char sChars[] = ". (@#$%*"; char sNums[] = " 1 234 567890"; if (SharesChar(pswd, uChars)false) return(false);Explanation / Answer
Required function is given below:
bool IsValidPassword(char pswd[], int minSize)
{
int n;
int i=0;
//length check
while(pswd[i]!='')
i++;
n=i;
if(n<minSize)
return false;
//uppercase check
i=0;
while(pswd[i]!='')
if(pswd[i]>='A' && pswd[i]<='Z')
break;
else
i++;
if(pswd[i]=='')
return false;
//lowercase check
i=0;
while(pswd[i]!='')
if(pswd[i]>='a' && pswd[i]<='z')
break;
else
i++;
if(pswd[i]=='')
return false;
//number check
i=0;
while(pswd[i]!='')
if(pswd[i]>='0' && pswd[i]<='9')
break;
else
i++;
if(pswd[i]=='')
return false;
//check symbol
i=0;
i=0;
while(pswd[i]!='')
if(pswd[i]=='!' || pswd[i]=='@' || pswd[i]=='#' || pswd[i]=='$' || pswd[i]=='%' || pswd[i]=='*')
break;
else
i++;
if(pswd[i]=='')
return false;
//If passes all checks
return true;
}
//If you have any doubt regarding the answer please ask in the comment section.
//Please upvote
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.