49. Reverse an integer by using Recursion

#include<stdio.h>
#include<conio.h>
int re (int,int,int*,int);
void main()
{
clrscr();
int i,j=0,n[5],k=0,m;
printf("Enter a number: ");
scanf("%d",&i);
m=re(i,j,n,k);
for(j=0;j<m;j++)
printf("%d",n[j]);
getch();
}
re(int i,int j,int *n,int k)
{
if(i==0) return k;
j=i%10;
n[k]=j;
i=i/10;
re(i,j,n,k+1);
program written by arnob;

No comments:

Post a Comment

free counters