Coding Lab - TechOnTechnology

Program in C# to Check whether a number is Palindrome or not

using System;
using System.Collections.Generic;
using System.Text;

namespace Lab_Ex_1
{
    class PalindromeProgram
    {
        static void Main(string[] args)
        {
            Console.Write(" Enter any number: ");
            int num = int.Parse(Console.ReadLine());
            int rev = 0, n, rem;
            n = num;
            while (num != 0)
            {
                rem = num % 10;
                rev = rev * 10 + rem;
                num = num / 10;
            }
            Console.WriteLine(" \n Original number is  " + n);
            Console.WriteLine(" \n Reversed number is  " + rev);
            if (n == rev)
            {
                Console.WriteLine("\n Original number = Reversed number.");
                Console.WriteLine("\n So, {0} is Palindorme ", n);
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("\n Original number != Reversed number.");
                Console.WriteLine("\n So, {0} is not a Palindorme ", n);
                Console.ReadLine();
            }
        }
    }
}

Name

Email *

Message *