Exclusive Clothing Sale On Flipkart

Get up to 50% off on our latest collection.

Shop Now

Reverse a number in C#

 

Reverse a number in C#

        public static void ReversedNumber()

        {

            int n, reverse = 0, rem;

            Console.Write("Enter a number: ");

            n = int.Parse(Console.ReadLine());

            while (n != 0)

            {

                rem = n % 10;

                reverse = reverse * 10 + rem;

                n /= 10;

            }

            Console.Write("Reversed Number: " + reverse);

        }


Output



Share this

Related Posts

Previous
Next Post »

Exclusive Clothing Sale On Flipkart

Get up to 50% off on our latest collection.

Shop Now