Hi,
Use the following code if you want to reverse the digits of a number using C Sharp/C #.
using System; class MainClass { public static void Main() { int urNum; int urdigits; urNum = 123; Console.WriteLine("Given Number: " + urNum); Console.Write("Reversed Number: "); do { urdigits = urNum % 10; Console.Write(urdigits); urNum = urNum / 10; } while(urNum > 0); Console.WriteLine(); } }
Output :
Given Number: 123
Reversed Number: 321
🙂