+ 1

My code passes all the test cases except the 7th test case in password validation codecoach problem.wht is the error in this

#include <stdio.h> #include <string.h> #define max 100000 int main() { char arr[max]; int c_num=0,ch_num=0,i; fgets(arr,sizeof(arr),stdin); int size=strlen(arr); for(i=0;i<size;i++) { if(arr[i]<=9 || arr[i]>=0) c_num++; if(arr[i]=='!' || arr[i]=='@' ||arr[i]=='#' ||arr[i]=='

#x27;||arr[i]=='%'||arr[i]=='*'||arr[i]=='&') ch_num++; } if(size>=7 && c_num>=2 && ch_num>=2) printf("Strong"); else printf("Weak"); }

10th Mar 2021, 2:49 PM
Hana Jiffry
Hana Jiffry - avatar
2 Antworten
+ 3
Number characters are in the range 48 to 57 inclusive. Not 0 to 9. Also your if(arr[i]<=9 || arr[i]>=0) is not the correct expression to check if a character is between '0' and '9' even if you fix the previous mistake.
10th Mar 2021, 3:04 PM
Dennis
Dennis - avatar
0
Thank u soo much😇😇
10th Mar 2021, 3:09 PM
Hana Jiffry
Hana Jiffry - avatar