Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code must be in C programming, include to read and write to file, and a switch statement Code and Decode your secrete message in C

Code must be in C programming, include to read and write to file, and a switch statement

image text in transcribed

 
Code and Decode your secrete message in C language. Type some text message in input.txt, then read the input.txt, shift each alphabet forward by 3 position. The shifted message should be saved in a file output.txt. The Shifted Alphabet Code is very very easy to do. Begin by writing down the alphabet in order on a piece of paper (or use the one below). ABCDEFGHIJKLMNOPQRSTUVWXYZ Now pick a number between 1 and 25. Got it? I picked the number 3. Now, when you write down your coded message, instead of writing the real letter, you find that letter in the alphabet and count forward - as many letters as the number you picked. So, if my message was "HI, HOW ARE YOU?" I would begin by finding the letter H, then counting forward three letters, to get the letter K. Then, since the next letter is I, find the land count forward to get the letter L. Keep going through the whole message like that. Uh oh...what about punctuation (like that question mark at the end of "Hi, HOW ARE YOU?"? Just leave that exactly the way it is. So you need to check first if the character is letter or not. Consider switch statements in C. Uh oh again! what happens when I get to the letter Y? I can't count forward 3 letters, because there aren't enough letters in the alphabet! That's okay...just start over at the beginning, after you count the Z. So Y becomes B! Is this code difficult to decode? In order to decode it, you need to know how many letters the message was shifted in the first place! Of course, if you don't know, it's not impossible...you just have to "unshift" it one letter at a time, until you get a message that makes sense! Do you think people use this code for things they need to keep secret? No, they don't. Because it's too easy to decode. But it's still fun to play with. Here is the ASCII table for all letters. https://simple.wikipedia.org/wiki/ASCII In C programming, a character variable holds ASCII value (an integer number between 0 and 127) rather than that character itself. This integer value is the ASCII code of the character. For example, the ASCII value of 'A' is 65. What this means is that if you assign 'A' to a character variable, 65 is stored in the variable rather than 'A' itself. Now, let's see how we can shifted a letter by 3 by adding 3 to ASCII value in this example

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago