Reverse number program in c#

Reversing given number without using any built-in function or method just use only basic function, this is often asked question in the interview.

Following sample code is for reversing number using simple basic function, method takes only a number as input and returns reversed number of given input number in c#.

WAP For Reverse Number - Code in C#


public int reverseNumber(int Number)
{
    int ReverseNumber = 0;
    while(Number > 0)
    {
        ReverseNumber = (ReverseNumber * 10) + (Number % 10);
        Number = Number / 10;
    }
    return ReverseNumber;
}

Output :

Entered Number : 11223344
Output Number : 44332211


Recent Article