C# Program to reverse number

C# Program to reverse number

We can reverse a number in C# using loop and arithmetic operators. In this program, we are getting number as input from the user and reversing that number.

Let’s see a simple C# Program to reverse number.

using System;
namespace CodelernerConcept
{
     class Program
     {
        static void Main(string[] args)
        {
            int n,rev = 0,i;
            Console.WriteLine("Enter The Number: ");
            n = int.Parse(Console.ReadLine());

            while (n > 0)
            {
                i = n % 10;
                rev = rev*10 + i;
                n = n / 10;
            }
            Console.WriteLine("Reverse Number Is: " + rev);
            Console.ReadKey();

        }
     }
}

OutPut :

Enter The Number : 123456789
Reverse Number Is: 987654321

C# Program to reverse number

Learn More Tutorial :

Leave a Reply

Your email address will not be published. Required fields are marked *