int n = 685; int remain = 0; int final = 0; for (int i = 0; i < 10; i++) { if (n > 0) { remain = n % 10; n /= 10; final = final * 10 + remain; } }