C# Program to Display the Reverse of a Number

Introduction

This program in C# developed using .NET Framework , C# and Visual Studio  will demonstrate how to get the reverse of a number and display it in the console window of the Visual Studio.

For example , if the input number is 1234 , the display output will be 4321.

C# Program to  Display the Reverse of a Number

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

namespace GinktageConsoleApp
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            int input;
            int result = 0, temp;
            Console.WriteLine("Enter the Number : ");
            input = int.Parse(Console.ReadLine());
            while (input != 0)
            {
                result = result * 10;
                temp = input % 10;
                result = result + temp;
                input = input / 10;
            }

            Console.WriteLine("Reverse of the Number is " + result);

            Console.ReadLine();
        }
    }
}

Output

Enter the Number :
1234
Reverse of the Number is 4321

image

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


x

Interesting BlogPosts to read

How to print title on every page in Microsoft Excel?
Most of the time we might end up having a long workbook with huge amount of data and they have lot o...
How to quickly remove multiple line breaks in Excel using VBA code?
There are times when you might copy few data from different source and you would end up getting unne...
How to change orientation of the worksheets in Microsoft Excel ?
This blog post will show the steps that are needed to change the orientation of the current workshee...