Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Upendra code for recurssion using function
- #include <stdio.h>
- #include <math.h>
- int fun(int);
- int main()
- {
- int a,result;
- printf("Enter the no \n");
- scanf("%d",&a);
- result=fun(a);
- printf("Reverse result is %d",result);
- }
- int fun(int a)
- {
- int r,c=-1,b=a,p;
- if (a!=0)
- {
- r=a%10;
- do
- {
- b=b/10;
- c=c+1;
- }
- while(b!=0);
- p=pow(10,c); // pow(10,c) = 10^c , if you include "#include<math.h>" at top then you can use power function i.e pow(x,y) .....
- return (r*p+fun(a/10));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement