Sure, here is a C# program to reverse the order of a number:
C#
using System;
public class ReverseNumber {
public static void Main(string[] args) {
int number = int.Parse(Console.ReadLine());
int reversedNumber = 0;
while (number > 0) {
int digit = number % 10;
reversedNumber = reversedNumber * 10 + digit;
number /= 10;
}
Console.WriteLine("Reversed number: " + reversedNumber);
}
}
This program works by first getting the number from the user. Then, it uses a loop to reverse the order of the digits in the number. Finally, it prints the reversed number to the console.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
int num = 98547, res = 0;
Console.WriteLine("Actual Number is : {0}", num);
while (num != 0)
{
res = res * 10;
res = res + num % 10;
num = num / 10;
}
Console.WriteLine("Number after reverse : "+res);
Console.ReadLine();
}
}
}
Output:
Actual Number is : 98547
Number after reverse : 74589
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Sure, here is a C# program to reverse the order of a number:
C#
This program works by first getting the number from the user. Then, it uses a loop to reverse the order of the digits in the number. Finally, it prints the reversed number to the console.
Here is an example of how the program would work:
Code snippet
There is a simple C# program to reverse the order of a given number,