Write a program to encrypt the data in a way that inputs a
four digit number and replace each digit
by (the sum of that digit plus 7) modulus 10. Then sweep the
first digit with the third, second digit
with the fourth and print the encrypted number.
Answer / Arun Prakash Gupta
Here's a simple C++ program that accomplishes the encryption process you described:
```
#include <iostream>
using namespace std;
void swap(int& a, int& b) {
int temp = a;
a = b;
b = temp;
}
int main() {
int number;
cout << "Enter a 4-digit number: ";
cin >> number;
// Encrypt each digit
number = (number / 1000 + 7) % 10 * 1000 +
(number / 100 % 10 + 7) % 10 * 100 +
(number / 10 % 10 + 7) % 10 * 10 +
(number % 10 + 7) % 10;
// Swap first and third digits, second and fourth
swap(number / 1000, number % 10);
swap((number / 100) % 10, number % 100 / 10);
cout << "Encrypted number: " << number;
return 0;
}```
| Is This Answer Correct ? | 0 Yes | 0 No |
Write a program to find the Fibonacci series recursively.
What are the types of STL containers?
Can manipulators fall in love?
What is a constructor and how is it called?
class Foo { const int x; protected: Foo(int f); ~Foo(); }; Foo f; Referring to the sample code above, why will the class declaration not compile? a) The variable x is const. b) The destructor is protected. c) The destructor is not public. d) The constructor is protected. e) There is no default constructor.
What is the output of printf("%d")?
58 Answers CTS, HCL, Infosys, TCS, Winit, Wipro,
What are the three types of access specifiers in C++?
plz send me National informatics center paper pattern
Program to check whether a word is a sub-string or not of a string typed
What new()is different from malloc()?
Keyword mean in declaration?
What are the c++ access specifiers?