Q:

Rotate left side

I have an integer.
Suppose n=25314; 
I want to rotate the digits on the left side of an integer(n) n times.
For ex. int=25314 and 3 time rotate left side .so, result is int=14253
int =32546 and 4 time rotate left side .So, result is int=63254
How do I rotate an integer left side with nth times in c++?

A:

1234567 / 1000 = 1234, with remainder 567.
Then just put them back together in the reverse order.
You do need to calculate x, which is the power of 10 higher than d.
(That's the loop.)
int n = 1234567;
int p = (int)pow(10, 3); // if you want to rotate by 3 digits
int d = n / p; // = 1234
int r = n - d * p; // = 567
int x = 1;
while(x <= d) x *= 10; // = 10000
int result = r * x + d; // = 5670000 + 1234 = 5671234

