Friday, 4 July 2014

Reverese the Integer in C# Console Application



Reverese the Integer in C# Console Application

Descriptions: Here, I will write a simple program in c# to reverse the integer.

static void Main(string[] args)
 {
int n = 12345;
int left = n;
int rev = 0;

while(left>0)
{
               r = left % 10;
               rev = rev * 10 + r;
               left = left / 10;
}

               Console.WriteLine(rev);
}

No comments:

Post a Comment