C# Program - Check whether a number is palindrome or not | Digital Infotainment

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, temp, rev=0, pal;
            Console.Write("Enter a number");
            n = int.Parse(Console.ReadLine());
            pal = n;
            do
            {
                temp = n % 10;
                rev = rev * 10 + temp;
                n = n / 10;
            } while (n!=0);
            if(rev==pal)
            Console.Write("The number is Palindrome");
            else
            Console.Write("The number is not Palindrome");
            Console.ReadKey();
        }
    }
}

/*Do leave a comment if you find this useful*/

No comments:

Post a comment