# Thread: How do I swap these digits?

1. ## How do I swap these digits?

This program reads a four-digit integer, and encrypts it. I have had to replace each digit by the sum of that digit plus 7 modulus 10. The final step is the swap digit1 with digit3 and swap digit2 with digit4. But I am not quite sure how to do that. Could somebody help me out please?

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

int main(int argc, char* argv[])
{
int Integer;
int Divider;
int Digit1, Digit2, Digit3, Digit4;

cout << "Enter a four-digit integer: ";
cin >> Integer;

Divider = 1000;
Digit1 = Integer / Divider;

Integer = Integer % Divider;
Divider = 100;
Digit2  = Integer / Divider;

Integer = Integer % Divider;
Divider = 10;
Digit3  = Integer / Divider;

Integer = Integer % Divider;
Divider = 1;
Digit4  = Integer / Divider;

Digit1 = (Digit1 + 7) % 10;
Digit2 = (Digit2 + 7) % 10;
Digit3 = (Digit3 + 7) % 10;
Digit4 = (Digit4 + 7) % 10;

cout << Digit1 << Digit2 << Digit3 << Digit4;

getch();
return 0;
}

2. Move digit1 to temp value
move digit3 to digit1
move temp to digit3

3. may not even have to perform the swap:
cout << Digit3 << Digit4 << Digit1 << Digit2;
could also suffice, if the program ends there

4. std::swap?