1. ## Return 4 Values

How can I return 4 values???

Code:
```#include <iostream>
using namespace std;

double encrypt(int number)
{
int digit1, digit2, digit3, digit4, encrypt1, encrypt2, encrypt3, encrypt4;

digit4 = number % 10;
digit3 = ((number % 100) - digit4)/10;
digit2 = ((number % 1000) - digit3)/100;
digit1 = ((number - number % 1000))/1000;

encrypt1 = (digit3 + 7)%10;
encrypt2 = (digit4 + 7)%10;
encrypt3 = (digit1 + 7)%10;
encrypt4 = (digit2 + 7)%10;

}
int main()
{
int num;

cin>>num;
cout<<encrypt(num);

}```

2. Pass an array of 4 ints, then write your 4 values into that array.

3. How? Thats chapter 7 in our book and were only in chapter 4,is there another way???

4. So, how does chapter 4 tell you to do it?

5. You could return an array and have an (inline) function to print out that array. It may look obscure, unless you want to use dynamic memory:

Code:
`// Edited out the solution.`

6. Chapter 4 is about algorithm,pseudocode,loops,and if statements.Which one is useful?

7. Erm, none of them really covers returning of multiple values.
There are 3 ways, that I can see:
- Create a structure to hold the data.
- Create an array to hold the data.
- Pass 4 variables directly.

And they can be used in 2 ways:
- Pass a structure/array by reference to the function.
- Create a temporary structure and return it.
- Create an array using dynamic memory (new/std::vector/std::tr1::array/std::tr1::shared_ptr) and return it.

The last can be used in simply one way: by passing 4 variables by reference to hold the data you want to return.
Pick a method you know.

8. Honestly I dont know any of that.Maybe I,m doing something wrong.

Heres what im supposed to do:

(Cryptography) 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 four-digit integers. The company has asked you to write
a program that encrypts the data so that it can be transmitted more
it as follows: Replace each digit by (the sum of that digit plus 7)
modulus 10. Then, swap the first digit with the third, swap the second
digit with the fourth and print the encrypted integer. Write a separate
program that inputs an encrypted four digit integer and decrypts it to
form the original number.

--------------------------------------------------
Sample Run of the encrypting program
--------------------------------------------------

Enter numbers to encrypt (0000 to end):

1234 1111 3290 1800 0000

The encrypted numbers are:

0189 8888 6709 7785

--------------------------------------------------
Sample Run of the decrypting program
--------------------------------------------------

Enter numbers to decrypt (0000 to end):

0189 8888 6709 7785 0000

The decrypted numbers are:

1234 1111 3290 1800

9. Perhaps you are meant to add them up into a single integer:

Code:
`return encrypt1 + encrypt2 * 10 + encrypt3 * 100 + encrypt4 * 1000;`

10. I tried that, but what if theres a zero?

11. Originally Posted by anon
Perhaps you are meant to add them up into a single integer:
Hmm, but that might remove leading 0's.

12. Yes, but if the answer you get back is 17, you know the answer is therefore "0017". How is this hard?

13. Ill just try this next week.Ill ask my professor if I could use arrays

14. The leading zeros is nothing but output formatting.

15. but what if the 0 is in the tenths place