Reversing the numbers - c# program, DOT NET Programming

Reversing the Numbers - C# Program

Hello guys i need your advice. How can i reverse the integer number in c# project? Please recommend some examples.

Posted Date: 2/11/2013 8:26:25 AM | Location : United States

Some new learner of C# faces this type of problem. Don''t worry use this code once.

using System;  

class ReverseNumber


  public static void Main()


   int num,rem,i,counter=0,temp;

   // num : Contains the actual number inputted via the console

   // rem : remainder of the number ''num'' when divided by 10

   // i : loop variable

   // counter : determines the no. of digits in the inputted number ''num''

   // temp : temporary variable used to save the value of ''num'' (Explained further)  

  Console.Write("Enter an integer number (Not more than 9 digits) : ");

  num = int.Parse(Console.ReadLine());    

  temp = num;

   // Here we are saving ''num'' in ''temp'' coz its value after determining the no. of digits will loose.

   // So after its work is done, ''num'' will contain value = 0

   // The value of ''num'' is resetted to its original value later from ''temp'' variable



   // Determine the no. of digits in the inputted number

   while(num > 0)


   rem = num % 10;

   num = num / 10;

    if (num <= 0) 






    counter = counter + 1;



  Console.WriteLine("Number of digits are = " + (counter+1));

  Console.Write("The reversed digits are : ");  

  rem = 0;

   // resetting the value of remainder ''rem''

   num = temp;

   // resetting the lost value of ''num'' from ''temp''  

   // *** Determine the reversed of inputted digits ***  

// Funda :

 // 1) Divide the number by 10 & determine the remainder. (Save the remainder in ''rem'') 

   // This will give us the last digit in the actual inputted number.   

   // 2) Write the number so obtained into the console  

   // 3) Divide the same number by 10 & get the quotient this time. 

   // Since division is between the integers, we will get the new number, deprived of the last digit.

   // Then again goto step 1) & continue until & unless the counter is equal to ''i'' (coz thats the loop varibale)  

   for(i = 0; i<=counter; i++)


      rem = num % 10;


   num = num / 10;   





Posted by diana | Posted Date: 2/11/2013 8:27:25 AM

Related Discussions:- Reversing the numbers - c# program, Assignment Help, Ask Question on Reversing the numbers - c# program, Get Answer, Expert's Help, Reversing the numbers - c# program Discussions

Write discussion on Reversing the numbers - c# program
Your posts are moderated
Related Questions
What is MVC pattern? The main purpose  of using  the MVC pattern is to decouple the GUI from the Data. It also gives the ability to provide multiple views for the same Data. Th

What are the differences between ASP and ASP .Net ?  ASP: Code is Interpreted ASP.NET: Code is Compiled   ASP: Business Logic and Presentation Logic are in a one

Construct a .NET wrapper for a C++ Dll - repost Project Description: We have a classic VC++ Dll (source code of DLL not required) that requires a .NET wrapper built by you. U

Project Description: Step 1: Buy 1 share at existing market price (ex: buy 1 at 100.00) If 4 points profit then close position if not go to step 2 Step 2: if 2 point

Project Description: System is used for tracking company's activities through several projects by keeping track of incomes and expenses per project. This project is fairly ea

What is ASP.NET Authentication Providers and IIS Security? ASP.NET executes authentication using authentication providers, which are code modules that determine credentials and

Explain the fundamental of connection pooling. Whenever a connection is opened first time a connection pool is created and is based on the exact match of the connection string

Briefly explain the characteristics of value-type variables that are supported in the C# programming language. The variables that are based on value types directly contain valu

Readymade NopCom 3.2 receptive website needs modifications. This is a developer/ webdesign (nopcommerce) opportunity which can allow a good developer/ designer the ability to creat

What is Absolute and Sliding expiration? The Absolute Expiration allows you to specify the duration of the cache, beginning from the time the cache is activated. The given exam