F C Program To Reverse A Number Using Recursive Function | CodeTheta

C Program To Reverse A Number Using Recursive Function

November 12, 2015

Here is a example of Reverse A Number Using Recursive Function which is written in CPP programming.revint() function can reverse any integer number.It is written in very simple way so that everyone can understand easily. If you got any error during execution time please inform us so that we can modify the bug or errors.

/* http://native-code.blogspot.com */
#include<stdio.h>
#include<conio.h>
Int revint(int);
Void main()
{
Int n,result;
Clrscr();
Printf(“/* http://native-code.blogspot.com */”);
Printf(“Enter The Number : ”);
Scanf(“%d”,&n);
Result=revint(n);
Printf(“The Reverse Of Number %d Is %d”,n,result);
Getch();
}
Int revint(int p)
{
Int d;
Static int r=0;
If(p==0)
{
Return(p);
}
Else
{
d=p%10;
r=r*10+d;
revint(p/10);
}
Return(r);
}
/* http://native-code.blogspot.com */

Output Of This Program

Enter The Number : 56789
The Reverse Of Number 56789 Is 98765

Test Environment IDE : Turbo C

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us

Post a Comment