I threw a for loop in and a function but if you aren't allowed to use functions you can use the same method in the 1st few posts.
This adds 7 to each digit then gets the remainder of each new digit by using mod 10 and then puts them in the 3412 order.
#include <iostream>
using namespace std;
int E(int exp) //function returns 10^exp
{
if( exp <= 0 )
return 1;
int r = 1;
for( int i = 0; i < exp; i++ )
r *= 10;
return r;
}
int main()
{
int num;
int digits[4];
cout << "Enter a 4 digit number to be encrypted: ";
cin >> num;
for( int i = 0; i < 4; i++ )
digits[3-i] = (((num%E(i+1))/E(i))+7)%10; //takes the digit from the input adds 7 and "mods" it to a 1 digit number
int temp[2] = {digits[0], digits[1]}; //stores these 2 digits because they get overwritten when changing the order
digits[0] = digits[2];
digits[2] = temp[0];
digits[1] = digits[3];
digits[3] = temp[1];
for( int i = 0; i < 4; i++ )
cout << digits[i] << endl;
return 0;
}