First, you have to determine these digits.
You can do so with
double tens = ((int)(x / 10)) % 10;
double thousands = ((int)(x / 1000)) % 10;
which enables you to do
x = x - (tens * 10.0) - (thousands * 1000.0) + (tens * 1000.0) + (thousands * 10.0);
which subtracts them at their original place and re-adds them in a swapped way.
You can optimize this to
x = x + tens * (1000.0 - 10.0) - thousands * (1000.0 - 10.0);
and, again, this to
x += (tens - thousands) * 990.0;