Friday, 23 September 2016

Reverse by Recursion

/* Reverse by Recursion */

#include<stdio.h>
int rev(int,int);

int main()
{
int a;
printf("Type a value : ");
scanf("%d",&a);
printf("Reverse: %d",rev(a,0));
return 0;
}

int rev(int i,int r)
{
if(i > 0)
return rev(i/10,(r*10)+(i%10));
return r;
}

No comments:

Post a Comment

Featured post

Will AI Replace Programmers? The Truth Behind the Hype in 2025

Exploring the Future of Coding: Will AI Take Over Software Development or Enhance It?  Will AI Replace Programmers? The Truth Behind the Hyp...