Answer to Question #124415 in C++ for Adomako

Question #124415
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-30T08:01:38-0400
#include <iostream>


int encrypt(int number) {
	int n1 = (number % 10 + 7) % 10;
	int n2 = (number / 10 % 10 + 7) % 10;
	int encrypted = n1 * 10 + n2;
	return encrypted;
}


int main() {
	std::cout << "Enter the number to encrypt: ";
	int number;
	std::cin >> number;
	std::cout << "Encrypted number: " << encrypt(number) << std::endl;
	system("pause");
	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
New on Blog
APPROVED BY CLIENTS