To find strength of the password

Question:
Find the strength of the password string based on the conditions.
Conditions:
- Length of the password is always greater than 8.
- It contains at least one numeral.
- It contains at least one symbol.
- It contains at least one uppercase alphabet.
Algorithm:
- Get the password from the user.
- Then check the length of the password is >8.
- Check for any numerals, symbols, and uppercase alphabets.
- Use marker variables for checking the at least one value(numerals, symbols, uppercase) is present in the string.
- Print the strength of the password.
Program:
[code lang=”c”]
#include<stdio.h>
void main()
{
//n->length of the string
//cnt->to count the strength
//f->as a marker for alphabets
//c->as a marker for numerals
//d->as a marker for symbols
//e->as a marker for upper case
char a[20],i,n,cnt=0,c=0,d=0,e=0,f=0;
clrscr();
printf("enter the password:");
gets(a);
n=strlen(a);
if(n>7) //enters only when length greater then 7
{
for(i=0;i<n;i++) { if(a[i]>=’a’&&a[i]<=’z’&&f==0) //checks for alphabets { cnt++; f=1; } else if(a[i]>=’A’&&a[i]<=’Z’&&f==0) //checks for alphabets { cnt++; f=1; } if(a[i]>=’0’&&a[i]<=’9’&&c==0) //checks for numerals { cnt++; c=1; } if(a[i]>=’!’&&a[i]<=’/’&&d==0) //checks for symbols { cnt++; d=1; } else if(a[i]>=’:’&&a[i]<=’@’&&d==0) { cnt++; d=1; } else if(a[i]>='{‘&&a[i]>=’~’&&d==0)
{
cnt++;
d=1;
}
if(a[i]>=’A’&&a[i]<=’Z’&&e==0) //checks for upper case
{
cnt++;
e=1;
}
}
}
switch(cnt) //prints the strength of password
{
case 1: printf("weak");
break;
case 2: printf("Medium");
break;
case 3: printf("Good");
break;
case 4: printf("Strong");
break;
default:printf("Not valid");
}
getch();
}
[/code]