C# Program to Check Whether a Number is Palindrome or Not

In this C# program, we will take input from the user and Check Whether a Number is Palindrome or Not. A number is a palindrome if the reverse of that number is equal to the original number.

C# Program to Check Whether a Number is Palindrome or Not Code:

private static void Main(string[] args)
        {
            int num, sum = 0, tempNum, remainder;
            Console.Write("Please enter the number: ");
            num = int.Parse(Console.ReadLine());
            tempNum = num;
            while (num > 0)
            {
                remainder = num % 10;
                sum = (sum * 10) + remainder;
                num = num / 10;
            }
            if (tempNum == sum)
            {
                Console.Write("Entered number {0} is a Palindrome number. ", tempNum);
            }
            else
            {
                Console.Write("Entered number {0} is not a Palindrome number. ", tempNum);
            }
            Console.ReadLine(); 
        }		

C# Program to Check Whether a Number is Palindrome or Not Output:

C#-Program-to-Check-Whether-a-Number-is-Palindrome-or-Not

C#-Program-to-Check-Whether-a-Number-is-Palindrome-or-Not

 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2024 CodingFusion
50+ C# Programs for beginners to practice