What is the the 7th test i passed all except 7th in password validation | SoloLearn: Learn to code for FREE!

+1

What is the the 7th test i passed all except 7th in password validation

Password validation https://code.sololearn.com/cSRc1au1894B/?ref=app

2/3/2020 11:34:51 AM

On!oN

9 Answers

New Answer

+2

You need to understand something basic. pass is an array of char, so if you want to compare each char you do like this if (pass[i] == '1' || pass[i] == '2' .....

+3

#include <stdio.h> main() { char s[100]; scanf("%s",&s); int i,length ,numbers=0, special_characters=0; length=strlen(s); for(i=0;i<length;i++){ if(s[i]>='0'&&s[i]<='9'){ numbers++; } else if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$'||s[i]=='%'||s[i]=='&'||s[i]=='*'){ special_characters++; } } if(length>=7 && special_characters>=2 && numbers>=2){ printf("Strong"); } else { printf("Weak"); } } You can try this one.. .

+1

What are you doing here? if(pass[i]==1||2||3||4||5||6||7||8||9||0) This is not the way to check if the char is equal to one of 0 to 9 use inbuilt function if (isdigit(pass[i]) { // your code }

+1

Better use isdigit for clean code.

+1

Thanks i should remember that i comparing char array to number.

+1

🕸️PronaY Sarker™🕸️ thanks Logic for checking no. Is pretty goods I should thinks about this.

0

~ swim ~ i try with if(pass[i]==1||pass[i]==2||pass[i]==4....) But again it show error

0

And 8 know that is wrong way but not getting the right way so i go through that..

0

I try with if (pass[i]==0) Num++; Else if (pass[i]==1) Num++; ... ... Else if(pass[i]==9) Num++; It also shows error ..