top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

    Get Free Article Updates

Facebook Login
Site Registration

Write a program to reverse a number using C#

0 votes
60 views

using System;

namespace Learn
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter a Number");
            int numb = int.Parse(Console.ReadLine());
            int reverse = 0;
            while (numb > 0)
            {
                int rem = numb % 10;
                reverse = (reverse * 10) + rem;
                numb = numb / 10;
               
            }
            Console.WriteLine("Reverse number={0}", reverse);
            Console.ReadLine();
        }
    }
}

 

Output
----------

Enter a Number
4567
Reverse number=7654

posted Feb 20, 2017 by Shivaranjini

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button


Related Articles

using System;

namespace Learn
{
    class Program
    {
        static void Main(string[] args)
        {
            string Str, Revstr = ""
            int Length;

            Console.Write("Enter A String : ");
            Str = Console.ReadLine();

            Length = Str.Length - 1;
            
            while (Length >= 0)
            {

                Revstr = Revstr + Str[Length];
                Length--;

            }

            Console.WriteLine("Reverse  String  Is  {0}", Revstr);

            Console.ReadLine();

        }
    }
}

 

OUTPUT
-------------

Enter A String : HELLO
Reverse  String  Is  OLLEH

READ MORE
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...