P18 To check whether the given number is palindrome or not



    class Program
    {
        static void Main(string[] args)
        {
            int n, r, d = 0, e;
            Console.Write("Enter the number : ");
            n = int.Parse(Console.ReadLine());
            e = n;
            while (n > 0)
            {
                r = n % 10;
                d = d * 10 + r;
                n = n / 10;
            }
            if (e == d)
            {
                Console.WriteLine(e + " is an palindrome number");
            }
            else
            {
                Console.WriteLine(e + " is not an palindrome number");
            }
            Console.ReadLine();
        }
    }

Output 1 : 

Output 2 :

No comments:

Post a Comment