C program to find Reverse of any number using recursion




#include<stdio.h>

void rev(int n, int cal);

int main( )

{

   int n,cal=0;


   printf("Enter the number: ");

   scanf("%d",&n);


   rev(n,cal);


   return 0;

}


void rev(int n, int cal)

{

   int i;


   if(n==0)

       printf("\nReversed no is: %d",cal);


   if(n>0)

    {

         i=n%10;

         n=n/10;

         cal=cal*10+i;

         rev(n,cal);

     }


}


Post a Comment

0 Comments