Reverse Number Program in C#


Prev Tutorial Next Tutorial

Reverse a Number Program in C#

To reverse any number we need to calculate remainder of number and the apply formula for reverse any number.

Formula

Remainder = Number % 10;  
Reverse = (Reverse * 10) + remainder;  
Number = Number / 10; 

Reverse a Number Program in C#

using System;  
  
namespace Reverse_Num  
{  
class Program  
{  
static void Main(string[] args)  
{  
Console.WriteLine("Enter any Number: ");  
int num = int.Parse(Console.ReadLine());  
int rev = 0;  
while(num>0)  
{  
int rem = Number % 10;  
rev = (rev * 10) + rem;  
num = num / 10;  
}  
Console.WriteLine("Reverse Number is: {0}",rev);  
Console.ReadLine();  
}  
}  
}

Output

Enter any Number: 154
Reverse Number is: 451

Output

Enter any Number: 247
Reverse Number is: 742

Prev Tutorial Next Tutorial

Google Advertisements
Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements