C Program to Find Product of 2 Numbers using Recursion
C Program to Find Reverse of a Number using Recursion
Problem Description
This C program finds the reverse of a number using recursion.
Problem Solution
The following C program using recursion reverses the digits of the number and displays it on the output of the terminal. Eg: 123 becomes 321.
Program/Source Code
#include
#include
int rev(int, int);
int main()
{
int num, result;
int length = 0, temp;
printf("Enter an integer number to reverse: ");
scanf("%d", &num);
temp = num;
while (temp != 0)
{
length++;
temp = temp / 10;
}
result = rev(num, length);
printf("The reverse of %d is %d.\n", num, result);
return 0;
}
i.... Show More
All Chapters — C programming
Similar Questions
From Recursive program in c · C programming
C Program to find LCM of two Numbers using Recursion
C Program to find whether a Number is Prime Or Composite using Recursion
C Program to find GCD of two Numbers using Recursion
C Program to Find Sum of Digits of a Number using Recursion
C Program to Print Binary Equivalent of an Integer using Recursion
Program to print Fibonacci Series using Recursion
C Program to Find Sum of N Numbers using Recursion