Hiding the contents of communications that can be viewed by entities other than
ID: 3885272 • Letter: H
Question
Hiding the contents of communications that can be viewed by entities other than the intended recipient could be done by encoding the message using a cypher and possibly a key known only the transmitting and receiving entities. Write a program that does the following. 1- Prompts the user to enter a word that is six letters long (all upper case). 2- Reads each character into a character type variable. 3- Ask the user for a cipher key, an integer between 2 and 8. 4- Store the Cipher key in an integer variable. 5- Add cipher key value to the ASCII value of each character. 6- Output the integer values adjusted by the cipher key on one line in the same order as the input with no spaces in between.Explanation / Answer
#include < stdio.h >
int main() {
// Initialize the six letters long word
char str[6];
//initialize the cipher value as int
int cipher;
//Prompts the user to enter the six letter long word
printf("Enter the Word: ");
gets(str);
//Ask the user for the cipher value between 2 and 8
printf("Enter cipher value between 2 and 8 : ");
//Storing the cipher key in an integer variable
scanf("%d", & cipher);
int i = 0;
//Add the cipher key value to the ascii value of each character and outputs the integer
for (i = 0; i < 6; i++) {
printf("%d", str[i] + cipher);
}
return;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.