Answer to Question #124436 in C++ for mike

Question #124436
6. A company wants to transmit data over the telephone, but is concerned that its phones could be tapped. All of the data are transmitted as two-digit integers. The company has asked you to write a program that encrypts the data so that it can be transmitted more securely. Your program should read a two-digit integer and encrypt it as follows: Replace each digit by (the digit plus 7) modulus 10). Then, swap the first digit with the second and print out the encrypted integer.
1
Expert's answer
2020-06-29T08:17:57-0400
#include <iostream>
#include <conio.h>
using namespace std;
int main(){
 int num_for_enscrypt;
 cout<<"Enter a 2-digit number for enscryption:";
 cin>>num_for_enscrypt;
 if (num_for_enscrypt<0||num_for_enscrypt>=100){
  cout<<"Incorrect number. Error.";
  getch();
  return 0;
  
 }
 int n1,n2;
 n1=num_for_enscrypt/10; //Determining the first digit;
 n2=num_for_enscrypt%10; //Determining the second digit;
 
 cout<<"Enscrypted number:"<<(n2+7)%10<<(n1+7)%10;
 getch();
 
}

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
New on Blog
APPROVED BY CLIENTS