Here is the source code of the C program to find the reverse of a number. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C program to find the reverse of a number using recursion
int rev(int, int);
int num, result;
int length = 0, temp;
printf("Enter an integer number to reverse: ");
temp = num;
while (temp != 0)
temp = temp / 10;
result = rev(num, length);
printf("The reverse of %d is %d.\n", num, result);
int rev(int num, int len)
if (len == 1)
return (((num % 10) * pow(10, len - 1)) + rev(num / 10, --len));
$ cc pgm34.c $ a.out Enter an integer number to reverse: 1234 The reverse of 1234 is 4321.
Sanfoundry Global Education & Learning Series – 1000 C Programs.
Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms