Help with simple decryption program plz!

Hi, I'm working on an assignment that says write a program that encrypts a 4-digit integer and and another program that decrypts it.

I'm having trouble writing the decrypt program because I don't know how to reverse the modulus operation.

To encrypt the 4-digit integer, replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the first digit with the third, and swap the second digit with the fourth. Then print the encrypted integer.

Here is the code to my encryption program. Thanks in advance!

Code:

`#include <iostream>`

using namespace std;

int main()

{

int num;

int d1, d2, d3, d4; //digits 1-4

int r1, r2, r3, r4; //remainders 1-4

int n1, n2, n3, n4; //digits 1-4 of encrypted number

cout << "Enter a 4-digit integer to encrypt: ";

cin >> num;

//separate each digit

d1 = num / 1000;

r1 = num % 1000;

d2 = r1 / 100;

r2 = r1 % 100;

d3 = r2 / 10;

r3 = r2 % 10;

d4 = r3 / 1;

r4 = r3 % 1;

//encrypt each digit

n1 = (d1 + 7) % 10;

n2 = (d2 + 7) % 10;

n3 = (d3 + 7 )% 10;

n4 = (d4 + 7) % 10;

//swap 1st digit with 3rd and 2nd with 4th

//Output new encrypted number

cout << "Encrypted number is: " << n3 << n4 << n1 << n2;

}