Verify if the given password is valid or not.
for a valid password it should follow these 2 condition
1. must be 5-12 characters long
2. must contain atleast one number and one lowercase & one upper character and a symbol
#include<stdio.h>
#include<string.h>
int main()
{
char S[20],c;
int i=0,l,L=0,U=0,N=0,Sy=0;
gets(S);
l=strlen(S);
if(l>12 || l<5)
{
printf("\n\Invalid password \n");
return 0;
}
while(S[i++]!=NULL)
if(S[i-1]>='a'&&S[i-1]<='z')
L=1;
else if(S[i-1]>='A'&&S[i-1]<='Z')
U=1;
else if(S[i-1]>='0'&&S[i-1]<='9')
N=1;
else Sy=1;
if(L&&U&&N&&Sy)
printf("\nvalid \n");
else printf("\n\Invalid password \n");
return 0;
}
Let me know your thoughts.