Tuesday, 2 January 2018

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);

     }


}


No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...