it takes the left digit using reminder operator
then multiple it with 10 to add the next digit at the right
usually I understand codes by printing the changes
check this may help
I can tell you how it is working but did you tried debugging it yourself?
Print the values of dig, rev and n after each iteration and see how it works. It is easy to understand. This is the most basic way of debugging.
thank you both of you for your support , I am new to coding , your help really counts
~ swim ~ thank you , I didn’t downvoted your answer intentionaly may be it was something in haste though I realised my mistake now . I would look forward for your help in future