Reverse Number
This algorithm reverse the given number. For example if given number is 123 then output number will be 321.
int Reverse(int num) {
int reverse = 0;
while (num != 0)
{
reverse *= 10;
reverse += num % 10;
num /= 10;
}
return reverse;
}
Example
int rev = Reverse(1234);
Output
4321