I'm supposed to make a program that lets you type in a password that has to be atleast 8 characters, with at least 2 digits.
Not sure if this is right, but I haven't been able to test it because i keep getting a syntax error before both of the "else" part of the program.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
int main()
{
char x[30];
int i=0;
int numdig=0, letters=0, ch;
printf("Enter Password:");
scanf("%s", x);
x[strlen(x)]= '\n';
while(gets(x)!= NULL)
{
if(isdigit(x[i]))
numdig++;
i++;
else if((islower(x[i])) || (isupper(x[i])))
letters++;
i++;
else
break;
}
if ((strlen(x)>= 8) &&(numdig>=2) )
printf("Valid Password\n");
else
printf("Invalid Password");
while ((ch = getchar()) != '\n' && ch != EOF);
getchar();
return 0;
}