Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hiding the contents of communications that can be viewed by entities other than

ID: 3885382 • 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 <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int main()
{
char ch[10];
int i, num;
printf(" Enter a word of 6 characters in UPPERCASE: ");
scanf("%s", ch);
printf(" Enter an Cipher Key as Integer value between 2 and 8: ");
scanf("%d",&num);
printf(" Cipher Key is = %d ",num);
printf(" The Cipher Value is: ");
for(i = 0; i < 6; i++)
{
//printf(" ASCII value of %c is %d", ch[i], ch[i]);
printf("%d",ch[i] + num);
}
return 0;
}


OUTPUT


Enter a word of 6 characters in UPPERCASE: STRING
Enter an Cipher Key as Integer value between 2 and 8: 6
Cipher Key is = 6
The Cipher Value is: 899088798477

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote