I can’t solve Password validation on C | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I can’t solve Password validation on C

I can’t understand what’s happened, last case is not valid, this case is 7, other cases are pass. So now I’ll put my code #include <stdio.h> #include <string.h> int weak(void); int main(void) { int num = 0; int first = 0, second = 0; char number[] = "0"; char symbol[7] = {'!','@','#','

#x27;,'%','&','*'}; char input[50]; int size; scanf("%s", input); size = strlen(input); if(size < 7) { weak(); return 0; } else for(int j = 0; j < size; j++) { for(int k = 0; k < 10; k++) { if(input[j] == number[k]) { first++; } } } for(int t = 0; t < size; t++) { for(int h = 0; h < 7; h++) { if(input[t] == symbol[h]) { second++; } } } if(first < 2 && second < 2) { weak(); return 0; } else printf("Strong"); return 0; } int weak(void) { printf("Weak"); return 0; }

25th Feb 2021, 11:51 PM
NoB0dy
NoB0dy - avatar
1 Answer
0
i don’t know the parameters of the tests. but at a glance, if first < 2 && second < 2 test .. maybe use || ?
26th Feb 2021, 12:00 AM
Jerry Hobby
Jerry Hobby - avatar