Welcome back,
I am back with the output blog for the program shared recently. If you want to try that program then visit last to last blog on my blog and for the explanation part visit the blog just before this blog.
Let us now look at the program itself.
You can see the program in written form below :
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;
}
Now without wasting anytime let us look at the output of this program.
So what you see above is how the output would look like for our program.
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.
I am happy to call myself a trader and small programmer at the same time now.
Happy trading and keep learning what you love.