Signup/Sign In
PUBLISHED ON: JANUARY 24, 2022

C Program to find Reverse of a Number using Recursion

Learn C language tutorial

Program To Find Reverse Of The Number Using Recursion:

#include <stdio.h>
#include <math.h>


int reverse(int n1);


int main()
{
    int n1, rev;

    printf("Enter The Number To Reverse: ");
    scanf("%d", &n1);
    
    rev = reverse(n1); 
    
    printf("The Reverse Of The Given Number Is %d = %d", n1, rev);
    
    return 0;
}

int reverse(int n1)
{
    int value = (int) log10(n1);
    
    if(n1 == 0)
        return 0;
    
    return ((n1%10 * pow(10, value)) + reverse(n1/10));
}

Output:

reverse number



About the author:
I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web development. I have 10 years of diverse experience in software development. Founder @ Studytonight