Program to reverse number in C#

C# Programming Language Loop control in C# Language (Article) Loop control in C# Language (Program)

279

Program:

using System;  
  public class ReverseExample  
   {  
     public static void Main(string[] args)  
      {  
       int  n, reverse=0, rem;           
       Console.Write("Enter a number: ");      
       n= int.Parse(Console.ReadLine());     
       while(n!=0)      
       {      
        rem=n%10;        
        reverse=reverse*10+rem;      
        n/=10;      
       }      
       Console.Write("Reversed Number: "+reverse);       
    }  
  }  

Output:

Enter a number: 234  
Reversed Number: 432

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about C# Programming Language. Then you can visit below links to get more depth on this subject.