SHARE
TWEET

Untitled

a guest Mar 20th, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Upendra code for recurssion using function
  2. #include <stdio.h>
  3. #include <math.h>
  4. int fun(int);
  5. int main()
  6. {
  7. int a,result;
  8. printf("Enter the no \n");
  9. scanf("%d",&a);
  10. result=fun(a);
  11. printf("Reverse result is %d",result);
  12. }
  13.  
  14. int fun(int a)
  15. {
  16.         int r,c=-1,b=a,p;
  17.     if (a!=0)
  18.     {
  19.     r=a%10;
  20.     do
  21.     {
  22.         b=b/10;
  23.         c=c+1;
  24.             }
  25.             while(b!=0);
  26.                 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) .....
  27.             return (r*p+fun(a/10));
  28.             }
  29. }
RAW Paste Data
Want to get better at C?
Learn to code C in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top