Reverse an Integer Number

To reverse a number we perform to operation one is to get remainder of the number and another is to get quotient in the original number.

Program:

using System;

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine("Enter a Integer Number");

            int number = Convert.ToInt32(Console.ReadLine());

 

            int length = number.ToString().Length;

            string reverseNumber = string.Empty;

 

            for (int i = 0; i < length; i++)

            {

                reverseNumber += (number % 10).ToString();

                number = number / 10;              

            } 

            Console.WriteLine(reverseNumber);

            Console.Read();

        }

    }

}

Output:

reversenumber.PNG

Next Recommended Reading Reverse a Number and String in C#