dealing with integers

am working on encryption and would like to select and modify individual members of say a four digit integer. I achieved that with an array but would be glad if it could be done on an integer

its not an assignment, am just trying out something on my own
closed account (E0p9LyTq)
You might want to look at the bitwise operators:
http://www.tutorialspoint.com/cprogramming/c_bitwise_operators.htm
like in this code sample, am able to perform a simple encryption on the array members.
what i want is use an integer instead of the array
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int data[4]; // data to be encrypted
    int index, temporal;
    cout << "Enter the four digit integer:\nSeparate each digit with a space.\n";
    cin >> data[0] >> data[1] >> data[2] >> data[3];
   // perform step one of encryption process
    for( index = 0; index <= 3; index ++ )
    {
        data[ index ] = ( 7 + data[ index ] ) % 10;
    }
    // perform step two
    for( index = 0; index <= 1; index ++ )
    {
        temporal = data[ index ];
        data[ index ] = data[ index + 2 ];
        data[ index + 2 ] = temporal;
    }
It can't be done easily using decimal digits, but it's extremely easy to do upon the same number's binary representation using bitmath. Why won't that work for you?
Topic archived. No new replies allowed.