c code to reverse integer (recursion)

  • creverserecursion
  • how to reverse integer in c using recursion

    write a program to read an integer number and print the reverse of that number using recursion.

    Code

    #include <stdio.h> int revNumFunction(int num) { static int sum = 0, rem; if (num) { rem = num % 10; sum = sum * 10 + rem; revNumFunction(num / 10); } else return sum; } int main() { int num, revNum; printf("enter number: "); scanf("%d", &num); revNum = revNumFunction(num); printf("the number after reverse :%d", revNum); return 0; }