programming-examples/c-sharp/_Basic/C# Program to Get a Number and Display the Number with its Reverse.cs

31 lines
727 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Get a Number and Display the Number with its Reverse
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Program
{
class Program
{
static void Main(string[] args)
{
int num, reverse = 0;
Console.WriteLine("Enter a Number : ");
num = int.Parse(Console.ReadLine());
while (num != 0)
{
reverse = reverse * 10;
reverse = reverse + num % 10;
num = num / 10;
}
Console.WriteLine("Reverse of Entered Number is : "+reverse);
Console.ReadLine();
}
}
}
Enter a Number : 123
Reverse of Entered Number : 321