+ 1

could someone tell please why the code below prints all the possibilities for the entered password exept (strong pass plus weak

#include <iostream> using namespace std; int main(){ string s; int a,b,c,d=0; cout<<"enter password:"<<endl; cin>>s; if(s.length()>8){ for(int i=0;i<s.length();i++){ if(s[i]>'a' && s[i]<'z') a=1; if(s[i]>'A' && s[i]<'Z') b=1; if(s[i]>'0' && s[i]<'9') c=1; if (!(s[i]>'a' && s[i]<'z' || s[i]>'A' && s[i]<'Z' || s[i]>'0' && s[i]<'9')) d=1; } if(a+b+c+d==4) cout<<"Very strong password"<<endl; if(a+b+c+d==3) cout<<"strong password"<<endl; if(a+b+c+d==2) cout<<"weak password"<<endl; if(a+b+c+d==1) cout<<"Very Weak password"<<endl; } else cout<<"Your password should not be less than 8 chars!"<<endl; return 0; } note:my program checks if the password is not less than 8 chars and if it contains small,capital letters along with digits and symbols

6th Dec 2018, 3:43 PM
RiGeL
RiGeL - avatar
3 Antworten
+ 2
You should have = at all the > and <
6th Dec 2018, 3:59 PM
Gordon
Gordon - avatar
+ 1
You are right mate, thank you a lot
6th Dec 2018, 4:04 PM
RiGeL
RiGeL - avatar
+ 1
For the last condition, brackets each and before or them https://code.sololearn.com/c9PPh8emxNrN/?ref=app
6th Dec 2018, 4:06 PM
Gordon
Gordon - avatar