+ 2

Password Validation (C++)

I dont know why it is failing help pls. The description of the exercise is on the top of the code https://code.sololearn.com/c9mntRE244e6/?ref=app

15th Apr 2022, 1:05 PM
Antoner8
Antoner8 - avatar
4 ответов
+ 1
your comparison in if blocks are wrong.. For example: If you want compare if char ch is equal to '@' Or '&' or '!', you should do like : if (ch == '@' || ch== '&' || ch == '!' ) cout<< "special character"; your code gets equal values for cant , num , spl. hope it helps...
15th Apr 2022, 1:16 PM
Jayakrishna 🇮🇳
+ 1
Thank you i will try to do that
15th Apr 2022, 1:16 PM
Antoner8
Antoner8 - avatar
0
For better way, take special characters into array and compare with current character in a loop.. Or you can use isalpha(), isdigits() methods for simplicity.. Or chacking within a character range will also works.. Like : if ( ch>='1' and ch <= '9' ) num++; you're welcome...
15th Apr 2022, 1:23 PM
Jayakrishna 🇮🇳
0
IT WORKS!!
15th Apr 2022, 1:32 PM
Antoner8
Antoner8 - avatar