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

I need to write a code that encrypts a message. The user will enter an integer t

ID: 3567067 • Letter: I

Question

I need to write a code that encrypts a message.

The user will enter an integer that tells you how much to shift by (1-25).

The user is then prompted to enter a message.

The program should out put the message shifted that many times.

So and example

Please enter the shift amount:

1

Please enter message:

How are you?

Encrypted message:

Ipx bsf zpv?

I need to do this using another function outside of the main to do the encrypting and not using arrays. It should be done with the getchar() and putchar() functions.

Explanation / Answer

#include <stdio.h>
#include <string.h>
int main( )
{
   int shift =1, d;
   printf("Enter the Shift: ");
   scanf("%d",&shift);
  
   printf(" Enter the Text:");
   while (d != ' ')
   {
     d = getchar();
     d += shift;
     putchar(d);   
   }

   return 0;
}

----------------------------------------------------------------------------------------------------------------------------------

Output:

Enter the Shift: 1