Algorithm to Print Reverse Number
- Initialize rev_num = 0
- Iterate while num > 0
(a) Multiply rev_num by 10 and add remainder of num
divide by 10 to rev_num
rev_num = rev_num*10 + num%10;
(b) Divide num by 10
- Return rev_num.
In the below code, rev_num() is a function that will return a reverse number of the input number.