top of page
Writer's pictureanitadevkar

Program for checking password is good or not

Write a program to accept password from user with following conditions-

1. Minimum characters 6 and Maximum are 12

2. Atleast one digit and one characters

3.Atleast one special symbol(@,$,#)

Program:

#include<stdio.h>

#include<string.h>

int main()

{

char str[100];//string-array of character

int i=0,len=0;

int flag,flag1,flag2,flag3;

printf("Enter the password");

scanf("%s",str);

len=strlen(str);

printf("Password length is=%d\n",len);

if(len<6&&len>=12)

{

flag=1;

}

else

for(i=0;i<len;i++)

if(str[i]>=48||str[i]<=52)

{

flag1=0;

break;

}

else

flag1=1;

for(i=0;i<len;i++)

if((str[i]>=65||str[i]<=90))

{

flag2=0;

break;

}

else

flag2=1;

for(i=0;i<len;i++)

if((str[i]=='#'||str[i]=='$'||str[i]=='*'))

{

flag3=0;

break;

}

else

flag3=1;

if(flag==1||flag1==1||flag2==1||flag3==1)

{

printf("wrong password.....Please follow conditions");

}

else

{

printf("Entered Password is Good password=%s",str);

}

return 0;

}

Output:

Enter the password Pccoe#12

Password length is=8

Entered Password is Good password=Pccoe#12

7 views0 comments

Recent Posts

See All

C Program for pyramid of number

Program: #include <stdio.h> int main() { int i,j; for(i=5;i>0;i--) //for rows { for(j=1;j<=i;j++) //for columns j loop will iterate...

Program to print Triangle

Program: #include <stdio.h> int main() { int i,j; for(i=5;i>0;i--) //for rows { for(j=0;j<i;j++) //for columns j loop will iterate...

Comentarios


bottom of page