Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey I'm new and I kinda need help with this problem. #include // You may find it helpful to add extra functions here. Procedures that

image text in transcribedimage text in transcribed

Hey I'm new and I kinda need help with this problem.

#include  // You may find it helpful to add extra functions here. Procedures that // encipher/decipher the entire `msg` may be useful. // // Likewise, functions that encipher/decipher single letters will help reduce // code repetition. It is completely up to you whether to create these // functions, but we *highly* recommend you do for practice! // Determines ciphering for a given message and prints out the result void determine_ciphering(char letter1, char letter2, char letter3, char letter4) { // TODO: Complete this procedure. This is needed to compile your program. } //////////////////////////////////////////////////////////////////////////////// ///////////////////// DO NOT EDIT THIS MAIN FUNCTION /////////////////////////// //////////////////////////////////////////////////////////////////////////////// // This main function scans a message and then calls your determine_ciphering // procedure, passing in the message. int main(void) { // Have a think about how we might implement this with a `struct message` // once we've covered structs in the Thursday lecture! char letter1; char letter2; char letter3; char letter4; // Scan message into the four characters printf("Message: "); scanf( "%c %c %c %c", &letter1, &letter2, &letter3, &letter4 ); // Call your determine_ciphering function and pass in the message. determine_ciphering(letter1, letter2, letter3, letter4);

}

This was the code they sent through the file

Message Cipher Download message_cipher.c here, or copy it to your CSE account using the following command: \[ \$ \mathrm{cp} \text {-n /web/cs1511/23T1/activities/message_cipher/message_cipher. } c \text {. } \] Complete the C program which scans in a message and either enciphers or deciphers it. Each message will consist of a total of 4 letters. To encipher a message, we will scan in 4 numbers to add to each of these letters. For example, if we have the message "comp" And, we scanned in the following 4 numbers: 5272 Then, the message is enciphered to "hqtn" This is because the numbers are added to the letters respectively. Pull up an ascii table if you want to double check this! Now, we also would like to decipher enciphered messages. Consider we have the enciphered message from the previous example: "hqtn" Now, if we input the same numbers as before: 5272 Then, deciphering this message with these numbers should give us the original message: "comp" So, we say that deciphering a message instead subtracts these numbers from the letters rather than adding them. In this exercise, you will add the ability to both encipher/decipher a given message. You will only be given letters as input (can be lower or uppercase!) and will need to follow the rules above. There are 3 important notes on our ciphering technique: - Input numbers can be negative, for example if we want to encipher with the number , then we get - If an enciphered/deciphered letter goes outside the range of "a-z" then it must wrap around. This means that if an input letter is ' y ' and the corresponding input number is , then the enciphered letter is - There is no limit on an input number. This means that we could have an input letter like with a corresponding input number and the corresponding enciphered letter would be Here are are some examples for how your program should run: $ dcc message_cipher.c -o message_cipher $./ message_cipher Message: comp Would you like to encipher or decipher this message (e/d)? e Enter numbers to encipher by: 5203 hqms $./message_cipher Message: hqms Would you like to encipher or decipher this message (e/d)? d Enter numbers to encipher by: 5203 comp $./message_cipher Message: tree Would you like to encipher or decipher this message (e/d)? e Enter numbers to encipher by: 0011 trdf $./message_cipher Message: Vosc Would you like to encipher or decipher this message (e/d)? d Enter numbers to decipher by: 10011 Word $./message_cipher Message: CoLd Would you like to encipher or decipher this message (e/d)? e Enter numbers to encipher by: 29100403 FsZa $./message_cipher Message: FsZa Would you like to encipher or decipher this message (e/d)? d Enter numbers to decipher by: 29100403 cold

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions