Answer to Question #333177 in C for lota

Question #333177

Suppose you want to send a message to your friend but don’t want others to understand that message.

So, you have decided to encrypt the message.

Now, suppose the message is in a string variable called MSG. a) You have to encrypt the message and

change the string so that others cannot understand it. b) Again, decrypt the encrypted message.


1
Expert's answer
2022-04-25T04:43:06-0400


#include  <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
void shifr(char *s)
{
  for(int i=0;i<strlen(s);i++)
    {
      s[i]=(char)(int(s[i])+8);
    }
}
void deshifr(char *s)
{
   for(int i=0;i<strlen(s);i++)
    {
      s[i]=(char)(int(s[i])-8);
    }
}
int main() {
  char s[125]="Hello";
  shifr(s);
  printf("%s\n",s);
  deshifr(s);
  printf("%s\n",s);
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS