c) Swap the second digit with the fourth. Then print the encrypted four-digit integer.
OK, I did the first one (I think), but I need help switching the first with the third digit and the second with the forth. Can anyone help me with this?
#include
void main()
{
cout<<"Enter a four-digit number to be encrypted:";
char a[4];
cin >> a;
int b[4];
b[0]=(int(a[2])-int('0')+7)%10;
b[1]=(int(a[3])-int('0')+7)%10;
b[2]=(int(a[0])-int('0')+7)%10;
b[3]=(int(a[1])-int('0')+7)%10;
cout<<"Encrypted number is:";
for(int i=0;i<4;i++){
for swapping
int c;
c=b[0];
b[0]=b[2];
b[2]=c;
c=b[1];
b[1]=b[3];
b[3]=c;
and take the size of a 5.1 space for /0.you should declare a as: int a[5];
............................................................................ http://www.cprogramming.tk