Reverse number in C Sharp

Reverse number

Loop and arithmetic operators can be used in C#, to reverse a number.

Example:

using System;  
  public class Example  
   {  
     public static void Main(string[] args)  
      {  
       int  num, rev=0, rem;           
       Console.Write("Enter a Number: ");      
       num = int.Parse(Console.ReadLine());     
       while(num!=0)      
       {      
        rem = num%10;        
        rev = rev*10 + rem;      
        num/=10;      
       }      
       Console.Write("Reverse of the Number: " + rev);       
    }  
  }

Output:

Explanation:

In the above example, we are printing the reverse of the number taken as input from the user.

Please Share