how to find reverse number from given number using C# language

how to find reverse number from given number using C# language

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {

            int n, rev=0,i;
            Console.WriteLine("enter num..");
            n = int.Parse(Console.ReadLine());
            while (n > 0)
            {
                i = n % 10;
                rev = rev * 10 + i;
                n = n / 10;
            }
            Console.WriteLine("reverse num ={0}", rev);
            Console.ReadLine();
        }
    }
Input :  Enter the String  "123456789 "
OutPut : 987654321

Previous
Next Post »