Hi another exercise which im having problems with. In this challenge im given a four digit integer and encrypt each digit as follows. Replace each digit by the sum of that digit plus seven mod 10. Then swap 1st and 3rd digit places and 2nd with 4th. Heres what i got so far. I havent figured out yet how to swap them. Any thoughts on that ? No arrays allowed.
//Deitel problem 2.38
//Encrypted integer
#include <iostream>
using namespace std;
int main(){
int iCounter, iNumber = 4596,
iRemainder = 0, iCopy;
iCopy = iNumber;
for ( iCounter = 0; iCounter <= 1; iCounter++) {
do {
iRemainder *= 10;
if ( iCounter == 0)
iRemainder += ((iNumber % 10) + 7) % 10;
else
iRemainder += iNumber % 10;
iNumber /= 10;
}while( iNumber != 0 );
iNumber = iRemainder;
iRemainder = 0;
}
cout << " Old number " << iCopy << " new number " << iNumber << endl;
return 0;
}