I have been doing lots of exercises on the book that I have then I went to encryption. This is just a very simple encryption on the book. It says that you have to enter only 4 digit number and each digit must be encrypted using the following:

digit + 7 % 10, swap the first digit to the third digit, swap the 2nd digit to the fourth digit. Provide an option to decrypt the encrypted value as well.

I wrote down the solution before coding it.

Ex:

Code:
I input 1234

1 + 7  = 8
2 + 7  = 9
3 + 7  = 10
4 + 7  = 11

After getting the sum of the each digit + 7 I did: 


8 % 10 = 2   //this should be 2, if not, 0 - but the compiler displays 8
9 % 10 = 1   //this should be 1, if not 0 - but the compiler displays 9 
10 % 10 = 0 //expected value
11 % 10 = 1 //expected value as well