accept a number and print its reverse order
accept a number and print its reverse order
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Sep 8, 2013, 12:15 PM
Posted Sep 8, 2013, 5:57 AM
class Program
{
static void Main()
{
Console.Write("Enter any number: ");
string s = Console.ReadLine();
char[] arr = s.ToCharArray();
Array.Reverse(arr);
Console.Write("Reverse number: ");
Console.Write(arr);
Console.ReadLine();
}
}
Sanjeeb LenkaPosted Sep 8, 2013, 1:52 AM
try this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Class1
{
static void Main(string[] args)
{
Console.WriteLine("Enter a Number");
int numb = int.Parse(Console.ReadLine());
int reverse = 0;
while (numb > 0)
{
int rem = numb % 10;
reverse = (reverse * 10) + rem;
numb = numb / 10;
}
Console.WriteLine("Reverse number={0}", reverse);
Console.ReadLine();
}
}
}