0

Can anyone help me password validation in coach code using c++.I am getting 5/13 thanks in advance

//This is the code #include<iostream> #include<string.h> using namespace std; char pass[100]; int co=0; int co1; int co3=0; int main() { cin.getline(pass,10); co1=strlen(pass); for(int p=0; p<co1; p++) { if(pass[p]=='#' || pass[p]=='!' || pass[p]=='#' || pass[p]=='*' || pass[p]=='&' ||pass[p]=='*') { co++; } else if(pass[p]=='0'|| pass[p]=='1' || pass[p]=='2'||pass[p]=='3' || pass[p]=='4' || pass[p]=='5' || pass[p]=='6' ||pass[p]=='7' || pass[p]=='8' || pass[p]=='9' ) { co3++; } } if(co>=2 && co3>=2 &&co1>=7 ) { cout<<"Strong"; } else { cout<<"Weak "; } return 0; }

9th Jun 2021, 6:45 AM
Ronald Gavuna
Ronald Gavuna - avatar
2 Answers
+ 3
For one, you are reading only ten characters, which might not be sufficient. I guess you meant 100 in cin.getline()? Furthermore, some of the special characters you are comparing to are duplicate, while others are missing. You should check back on the description to see what special characters need to be counted.
9th Jun 2021, 9:26 AM
Shadow
Shadow - avatar
+ 1
Thanks Shadow
9th Jun 2021, 1:52 PM
Ronald Gavuna
Ronald Gavuna - avatar