0% found this document useful (0 votes)
17 views1 page

Password Check

The document contains a C program that checks the validity of a password based on specific criteria: it must be longer than 7 characters and contain at least one uppercase letter, one lowercase letter, one digit, and one special character. If the password meets these requirements, it is considered valid; otherwise, it is deemed invalid. The program outputs whether the provided password is valid or invalid.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Password Check

The document contains a C program that checks the validity of a password based on specific criteria: it must be longer than 7 characters and contain at least one uppercase letter, one lowercase letter, one digit, and one special character. If the password meets these requirements, it is considered valid; otherwise, it is deemed invalid. The program outputs whether the provided password is valid or invalid.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// Online C compiler to run C program online

#include <stdio.h>
#include <string.h>

int password_check(char *str){


int len = strlen(str);
int res =0;
int i,flag1,flag2,flag3,flag4;
if(len<7)
{
printf("Password lenghth should be grater than 7");
return res;
}
else
{
for(i=0;i<len;i++)
{
if(str[i]>='A' && str[i]<='Z'){
flag1=1;
}
else if(str[i]>='a' && str[i]<='z'){
flag2=1;
}
else if(str[i]>='0' && str[i]<='9'){
flag3=1;
}
else if(str[i]=='&' || str[i]=='#' || str[i]=='%' ||str[i]=='*' ||
str[i]=='$'){
flag4=1;
}

}
if(flag1==1 && flag2==1 && flag3==1 && flag4==1)
{
res=1;
}

}
return res;
}

int main() {
// Write C code here
printf("Try programiz.pro\n");
char *pass ="a1fghjkl";
int res=password_check(pass);
if (res == 0)
{
printf("INVALID PASSWORD\n");
}
else
{
printf("VALID PASSWORD\n");
}

return 0;
}

You might also like