Reverse Number Program in C#

Advertisements

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 Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements