#include #include void encrypt(char *message, int shift) { int len = strlen(message); for (int i = 0; i < len; i++) { if (message[i] >= 'A' && message[i] <= 'Z') { message[i] = (message[i] - 'A' + shift) % 26 + 'A'; } else if (message[i] >= 'a' && message[i] <= 'z') { message[i] = (message[i] - 'a' + shift) % 26 + 'a'; } } } void decrypt(char *message, int shift) { int len = strlen(message); for (int i = 0; i < len; i++) { if (message[i] >= 'A' && message[i] <= 'Z') { message[i] = (message[i] - 'A' - shift + 26) % 26 + 'A'; } else if (message[i] >= 'a' && message[i] <= 'z') { message[i] = (message[i] - 'a' - shift + 26) % 26 + 'a'; } } } int main() { char message[100]; int shift; printf("Enter a message: "); fgets(message, sizeof(message), stdin); printf("Enter the shift value: "); scanf("%d", &shift); // Remove newline from the message message[strcspn(message, "\n")] = 0; // Encrypt and print encrypt(message, shift); printf("Encrypted message: %s\n", message); // Decrypt and print decrypt(message, shift); printf("Decrypted message: %s\n", message); return 0; }