//Here's a function that does the job.
//Parameter n is the number to be reversed.
//This function returns the reversed number.
//Actually this function can reverse any digit numbers.
int reverse(int n)
int rev = 0; //this variable stores the reverse of n
while(n > 0)
rev = (rev * 10) + (n % 10);
n /= 10;
By careful examination of the code it will be clear how it works.