UncleCoder.com

UncleCoder.com

Free programming examples and instructions

C program to find reverse a number

c program for how to find reverse of a number any digit

by Krishna viswambharan


Posted on 31 Oct 2017 Category: C Views: 7

Edited on 20 Jul 2018


C program to find reverse a number

In this article we will see how to reverse a given number using while loop .  Source code for the program is given as follows. The program compile successfully and output is also shown below.

#include <stdio.h>
#include <conio.h>
int main()
{
    int n, reverse = 0, remainder;

    printf("Enter an integer: ");
    scanf("%d", &n);

    while(n != 0)
    {
        remainder = n%10;
        reverse = reverse*10 + remainder;
        n /= 10;
    }

    printf("Reversed Number = %d", reverse);
    getch();
    return 0;
}

output

 



Leave a Comment:


Advertisement