Thursday, June 27, 2013

Write a recursive function to find reverse of a given number.



long reverse(long n)
{
int rem;
int static rev=0;
if(n==0)
   return rev;
else
   {
   rem= n%10;
   rev=rev*10+rem;
   reverse(n/10);
   }
}

No comments:

Post a Comment