DEV Community

Abhijeet singh
Abhijeet singh

Posted on

C program is not working properly.

//wap to enter a password which contains uppercase, lowercase and digits in it?

include

include

include

int main()
{
char pass[10];
int a,b,c=0;
int i;
printf("enter a password:\n");
scanf("%s", pass);

for(i=0;i<10;i++){

   if(islower(pass[i])){
       a++;
    }
   if(isdigit(pass[i])){
        b++;
    }
   if(isupper(pass[i])){
        c++;
    }
}
    if((a>0) && (b>0) && (c>0)){
        printf("pass is legit.");
    }else{
        printf("pass is not valid.");
    }

    return 0;

}

Top comments (3)

Collapse
 
curtisfenner profile image
Curtis Fenner • Edited

You need to edit your post so that the code is formatted properly. You can use three ` before and after to do that. You should also explain what your program is supposed to do, and what's not working, rather than just dumping code without context.

Collapse
 
codemouse92 profile image
Jason C. McDonald

I hope you don't mind, Curtis, but I'm borrowing this comment for my collection of moderation comments. :)

Collapse
 
codemouse92 profile image
Jason C. McDonald

I agree with @curtisfenner . Also, you should use the #help tag in addition to the ones you're using; it'll attract more help (once the code is formatted to be legible).