Login to ask a question from Recursive program in c

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

Previous Question Next Question
🔗

Similar Questions

From Recursive program in c · C programming

View All
WhatsApp