Write a C# program to reverse given number.
using System; public class ReverseNumber { public static void Main(string[] args) { int number, reverse = 0, digit; Console.WriteLine("Enter a number: "); number = int.Parse(Console.ReadLine()); while (number > 0) { digit = number % 10; reverse = reverse * 10 + digit; number /= 10; } Console.WriteLine("The reversed number is: " + reverse); } }
Write a C# program to reverse given number.
Reviewed by Bhaumik Patel
on
1:34 AM
Rating: