Module1
Module1
Strong Password
#include <stdio.h>
#include <string.h>
// Function to determine the minimum number of characters to add
int minimumNumber(int n, char *password) {
int required_chars = 0;
int has_digit = 0, has_lower = 0, has_upper = 0, has_special = 0;
const char *special_characters = "!@#$%^&*()-+";
// Check the existing characters in the password
for (int i = 0; i < n; i++) {
if (password[i] >= '0' && password[i] <= '9') has_digit = 1;
else if (password[i] >= 'a' && password[i] <= 'z') has_lower = 1;
else if (password[i] >= 'A' && password[i] <= 'Z') has_upper = 1;
else if (strchr(special_characters, password[i])) has_special = 1;
}
int main() {
int n;
char password[101];
// Input the length of the password and the password itself
scanf("%d", &n);
scanf("%s", password);
// Calculate and print the minimum number of characters to add
int result = minimumNumber(n, password);
printf("%d\n", result);
return 0;
}
int main() {
int X, N;
printf("Enter X: ");// Input the values of X and N
scanf("%d", &X);
printf("Enter N: ");
scanf("%d", &N);
int result = powerSum(X, N); // Calculate and print the number of combinations
printf("%d\n", result);
return 0;
}