Showing posts with label reverse a number in c#. Show all posts
Showing posts with label reverse a number in c#. Show all posts

Friday, October 20, 2017

Reverse a Number in C#

Here is a very simple program that I wrote before as a simple programming activity in my upcoming book on C# programming. I will ask the user to give a number and then our program will reverse the arrangement of the given number by our user.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.



Program Listing

reverse.cs


using System;

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