+ 1
My test cases are getting failed. Can you correct it?
#include<iostream> #include<string.h> using namespace std; int main() { int i=0; int x=0,y=0,z=0; string password; cout<<"ENTER PASSWORD : "; getline(cin,password); while(password[i]!='\0') { if(isdigit(password[i])!=0) { x++; } else if(isalpha(password[i])!=0) { y++; } else if(password[i]=='!'||password[i]=='@'||password[i]=='#'||password[i]=='
#x27;||password[i]=='%'||password[i]=='*'||password[i]=='&') { z++; } i++; } if(x>=2&&y>=7&&z>=2) { cout<<"strong"; } else { cout<<"weak"; } return 0; }3 Answers
+ 4
you shouldn't use
cout << "Enter password" ;
it will be considered as output when the desired output should be only "Strong" or "Weak".
- strong and weak must start with a capital letter.
+ 1
Bahhađ§ I have done it but 4 out of 13 test cases are getting wrong.
0
get length of the password correctly.
int l = password.length();
just after password is received then
replace y >= 7 with l >= 7