In this tutorial, I am going to write Program to Reverse a Number and String in C#.

C# Program to Reverse a Number:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ReverseNumber
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“Enter a Number to Reverse”);
int iNumber = Convert.ToInt32(Console.ReadLine());
int iReverse = 0;
while (iNumber > 0)
{
int iRemainder = iNumber % 10;
iReverse = (iReverse * 10) + iRemainder;
iNumber = iNumber / 10;
}
Console.WriteLine(“Reverse Number is {0}”, iReverse);
Console.ReadLine();
}
}
}

Output:

ReverseReverse

 


Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, bool given in C:\inetpub\vhosts\debugonweb.com\httpdocs\wp-includes\wp-db.php on line 3353