C Program : Find the output for this Jumble Crypter

in c-programming •  last year 

Welcome back,
I am back with a new program and this one will surely be a interesting program compared to previous few programs shared here.

So are you ready for some brain bursting...

Let us move on to our program,

Screenshot 2023-07-26 220206.png

Screenshot 2023-07-26 220216.png

Screenshot 2023-07-26 220228.png

You can see the program in written form below :

#include <stdio.h>
#include <string.h>

void jumbleString(char* str) {
int length = strlen(str);
for (int i = 0; i < length - 1; i += 2) {
char temp = str[i];
str[i] = str[i + 1];
str[i + 1] = temp;
}
}

void encryptString(char* str, int shift) {
int length = strlen(str);
for (int i = 0; i < length; i++) {
if (str[i] >= 'A' && str[i] <= 'Z') {
str[i] = ((str[i] - 'A') + shift) % 26 + 'A';
} else if (str[i] >= 'a' && str[i] <= 'z') {
str[i] = ((str[i] - 'a') + shift) % 26 + 'a';
}
}
}

int main() {
char input_string[100];
char encrypted_form[100];
int shift;

printf("Enter a string: ");
fgets(input_string, sizeof(input_string), stdin);
input_string[strcspn(input_string, "\n")] = '\0'; // Remove the trailing newline from fgets

printf("Enter the encryption shift (a number between 1 and 25): ");
scanf("%d", &shift);

// Jumble the input string
jumbleString(input_string);

// Encrypt the jumbled string
strcpy(encrypted_form, input_string); // Make a copy of the jumbled string
encryptString(encrypted_form, shift);

// Output the results
printf("\nJumbled String: %s\n", input_string);
printf("Encrypted Form: %s\n", encrypted_form);

return 0;
}

image.png

Now it is time for you to find the correct output for the given program. I am not going to give options today to make it even more difficult.

If you also want to learn basics and start your C programming journey then find a teacher today for free on Youtube.

I learnt alot from a teacher who teaches c in hindi and if you are finding someone who teaches in hindi then this person will definitely help you.

Source

I am happy to call myself a trader and small programmer at the same time now.

Happy trading and keep learning what you love.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!