program should validate the input data (password) based on the following rules: The password length should have a minimum length of 6 and maximum of 15 characters Some characters aren’t allowed in the password including “space” and “-”. If user includesthese two characters in the input, the program should display “invalid password”.
Code:
int main()
{
char password[15];
int lenght;
int str;
printf("Please enter the password:\n");
printf("note:no space or - in password\n");
printf("note:min password lenght =6 and max password lenght =15\n");
fgets(password, 15, stdin);
int i = strlen(password);
if (i < 5 || i > 14) {
printf("please check the lenght rules ");
}
else if (i > 0) {
for (int j = 0; j <= i; j++) {
password[j] == ' ';
password[j] == '-';
}
printf("No space is allowed or any hypens - ,please try again");
} else
printf("registered");
}