This program prints a number with reversed digits. For example, if you input 3564, you'll get 4653.
Suppose you give , and let's see what the code does line by line:
We give 45 as input, and define .
Then, we enter the while loop. The instruction d = s%10 simply extracts the last digit from s. In this case, .
The istruction adds a 0 at the end of the current value of . Then we add , so now the last digit of is : we're performing
Finally, the integer division s = s//10 cuts the last digit from . So, after the first loop, we have
We enter the loop again. we have
The new value of is
And the division s//10 returns 0, so we exit the loop.
And indeed we have r=54, which is 45 in reverse.