Write a C# Program to reverse number

How to Write a C# program to find the reverse number of a number and  C# Code to reverse a number.

Example:

Input: 123455

Output: 554321

C# Program to reverse a number

using System;
 
namespace CSharpProgram
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, rev = 0, rem;
            Console.Write("Enter a number to find the reverse: ");
            n = int.Parse(Console.ReadLine());
            while (n != 0)
            {
                rem = n % 10;
                rev = rev * 10 + rem;
                n /= 10;
            }
            Console.Write("The Reversed Number of: "+n+" is " + rev);
            Console.ReadLine();
        }
        
    }
}

Add a Comment

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

five × four =