+ 1

Can you find what is wrong with this code ?Help me.

It always shows çzy or it is an invalid password whatever I do.This is a password validator which tells you when your password is correct(i.e. when it is 5-10 characters long, has uppercase letters and lowercase letters with symbols) or wrong. https://code.sololearn.com/c8XSLclP48Qs/?ref=app

6th Jun 2019, 5:24 AM
Bishal Biswal
Bishal Biswal - avatar
2 odpowiedzi
+ 2
Your question is not clear, as you have not mentioned what the code is supposed to do. Kindly provide more details regarding the problem you are trying to solve. When is a password correct? When it consists of digits, special characters in the range 33-47 and small case alphabets? If the above is true, then you have not implemented the code correctly: 0) The 3rd if condition inside the for loop checks if the ASCII code of a[i] is in the range 1 to 9. All ASCII characters in this range are non-printable, and so the condition will not check if a[i] is a digit. So, compare with '1' and '9' instead of 1 and 9. 1) The condition k==j && j==b will never be true. This is because when one of the conditions is satisfied, the other conditions fail. So if k becomes 1, j and b can never be 1. Thus the valid check condition fails. 2) In the for loop, the values of k, j and b are overwritten for every a[i]. Thus, when the loop terminates, the values of k, j and b correspond to the last character.
6th Jun 2019, 5:47 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 2
Okay thanks for your help though.
6th Jun 2019, 6:54 AM
Bishal Biswal
Bishal Biswal - avatar