C program to reverse a number

Problem

Write a program in C to display the reverse of a number.

The below program takes the input from the user in the form of an integer number and uses the while loop until the number becomes o.

How to reverse a number in C ?

#include <stdio.h>
int main()
{
    int input, output = 0, rem;
    printf("Abundantcode.com coding sample\n");
    printf("Enter a number: ");
    scanf("%d", &input);

    while(input != 0)
    {
        rem = input%10;
        output = output*10 + rem;
        input /= 10;
    }

    printf("Reverse Number = %d", output);

    return 0;
}

Output

Abundantcode.com coding sample

Enter a number: 786543

Reverse Number = 345687