Write a c program that allow a password which have minimum 6 alphabet ,at least 1 special symbol and at least 1 digits

 

Code:-

#include<stdio.h>
#include<string.h>
int main()
{
char pass[100];
int flag_spe=0,flag_dig=0,length,alpha=0,i;
printf(“Enter your password : “);
scanf(“%[^n]”,pass);
length=strlen(pass);
if(length<8)
printf(“Wrong password”);
else
{
for( i=0;pass[i];i++)
{
            // 48 is ascii of 0 and 57 is for 9
if(pass[i]>=48 && pass[i]<=57)
flag_dig=1;

            // 33 to 38 and 64 all are ascii of
            // special symbol
if((pass[i]>=33 && pass[i]<=38) || pass[i]==64)
flag_spe=1;

            // 65 to 90 and 97 to 122 all are ascii of
            // alphabet
if((pass[i]>=65 && pass[i]<=90) || (pass[i]>=97&&pass[i]<=122))
alpha++;
}
        // if all conditon satishfied then
if(flag_spe==1 && flag_dig==1 && alpha>=6)
printf(“password matched”);
else
printf(“Wrong password”);
}
return 0;
}

Write a c program that allow a password which have minimum 6 alphabet ,at least 1 special symbol and at least 1 digits Output of programe

Output:-

Enter your password : [email protected]
Password matched




Leave a Reply

Your email address will not be published.