Question

The following code is a C Program that is written for encrypting and decrypting a string. provide a full explanation of the working flow of the program.

#include <stdio.h> int main() { int i, x; char str[100]; printf(\n Please enter a valid string: \t); gets (str); printf (\

0 0
Add a comment Improve this question Transcribed image text
Answer #1

EXPLAINATION -

So, in the above code, at first user will enter a string of length upto 100.

After that, we have 2 choices. First, we can encrypt the given string i.e. we will change the original string. And the second option is , we can decrypt the string i.e. we are assuming the given string is itself a changed string and we have to retrieve our original string.

So, when we select the first choice we will change the original string. For that we are traversing the whole string and increasing the ASCII value of the characters by 3. This means if the given string is 'abcdef' , after completing the encryption , it will become 'defghi' which is nothing but out encrypted string.

Now, if we select the second choice, we have to retrieve the original string. For that, again we are traversing the whole string and this time decresing the value of characters by 3. This means if the given string is 'xsyrwh' , after completig the decryption, it will become 'upvote' which is our decrypted string that user want to retrieve.

And, if we select any choice other than these two, we will get the message - "Erorr in proces".

Add a comment
Know the answer?
Add Answer to:
The following code is a C Program that is written for encrypting and decrypting a string....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Study the VIGENÈRE CIPHER and implemented it with c++ 1.In your program, you should have two...

    Study the VIGENÈRE CIPHER and implemented it with c++ 1.In your program, you should have two functions: encryption and decryption. 2. Use any key you like. (Don't use deceptive in the slides) 3. choose a sentence or a paragraph you like as the plaintext. I have the code I just need the implementation in a different way // C++ code to implement Vigenere Cipher #include<bits/stdc++.h> using namespace std; // This function generates the key in // a cyclic manner until...

  • i'm trouble getting my program to print this output and repeat until asked to quit the...

    i'm trouble getting my program to print this output and repeat until asked to quit the program Enter a telephone number using letterss (EXIT to quit): GET LOAN The corresponding telephone number is: 438-5626 Here's my code: #include <stdio.h> #include <string.h> char getNumber(char aC) { char c = ' '; switch (aC) { case 'A': case 'B': case 'C': c = '2'; break; case 'D': case 'E': case 'F': c = '3'; break; case 'G': case 'H': case 'I': c...

  • C program (Not C++, or C#) Viginere Cipher 1)Ask the user if we are encrypting or...

    C program (Not C++, or C#) Viginere Cipher 1)Ask the user if we are encrypting or decrypting. 2) Ask the user to enter a sentence to be transformed. 3) Ask the user to enter a sentence that will be used as the encryption or decryption key. 4) The sentences (array of characters) should end with a NULL terminator '\0'. 5) The range of values will be all printable characters on the ASCII chart starting with a SPACE - Value 32,...

  • Using C++ Part C: Implement the modified Caesar cipher Objective: The goal of part C is...

    Using C++ Part C: Implement the modified Caesar cipher Objective: The goal of part C is to create a program to encode files and strings using the caesar cipher encoding method. Information about the caesar method can be found at http://www.braingle.com/brainteasers/codes/caesar.php.   Note: the standard caesar cipher uses an offset of 3. We are going to use a user supplied string to calculate an offset. See below for details on how to calculate this offset from this string. First open caesar.cpp...

  • Change the following Shift Cipher program so that it uses OOP(constructor, ect.) import java.util...

    Change the following Shift Cipher program so that it uses OOP(constructor, ect.) import java.util.*; import java.lang.*; /** * * @author STEP */ public class ShiftCipher { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner(System.in); String plainText; System.out.print("Please enter your string: "); // get message plainText = input.nextLine(); System.out.print("Please enter your shift cipher key: "); // get s int s = input.nextInt(); int...

  • Here is a serial program in C and parallel program in OpenMP that takes in a string as input and counts the number of occurrences of a character you choose. Why is the runtime for the output for the O...

    Here is a serial program in C and parallel program in OpenMP that takes in a string as input and counts the number of occurrences of a character you choose. Why is the runtime for the output for the OpenMP parallel program much longer? Serial Program #include <stdio.h> #include <string.h> #include <time.h> int main(){    char str[1000], ch;    int i, frequency = 0;    clock_t t; struct timespec ts, ts2;       printf("Enter a string: ");    gets(str);    int len = strlen(str);    printf("Enter a character...

  • Finish function to complete code. #include <stdio.h> #include <stdlib.h> #include<string.h> #define Max_Size 20 void push(char S[],...

    Finish function to complete code. #include <stdio.h> #include <stdlib.h> #include<string.h> #define Max_Size 20 void push(char S[], int *p_top, char value); char pop(char S[], int *p_top); void printCurrentStack(char S[], int *p_top); int validation(char infix[], char S[], int *p_top); char *infix2postfix(char infix[], char postfix[], char S[], int *p_top); int precedence(char symbol); int main() { // int choice; int top1=0; //top for S1 stack int top2=0; //top for S2 stack int *p_top1=&top1; int *p_top2=&top2; char infix[]="(2+3)*(4-3)"; //Stores infix string int n=strlen(infix); //length of...

  • Language is in C. Need help troubleshooting my code Goal of code: * Replace strings with...

    Language is in C. Need help troubleshooting my code Goal of code: * Replace strings with a new string. * Append an s to the end of your input string if it's not a keyword. * Insert a period at the end, if you have an empty input string do not insert a period Problems: //Why does my code stop at only 2 input strings //If I insert a character my empty string case works but it's still bugged where...

  • 1. You are given a C file which contains a partially completed program. Follow the instructions...

    1. You are given a C file which contains a partially completed program. Follow the instructions contained in comments and complete the required functions. You will be rewriting four functions from HW03 (initializeStrings, printStrings, encryptStrings, decryptStrings) using only pointer operations instead of using array operations. In addition to this, you will be writing two new functions (printReversedString, isValidPassword). You should not be using any array operations in any of functions for this assignment. You may use only the strlen() function...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT