C# Program to check Palindrome number

In this article, I will be writing a C# Program to check the Palindrome number. I will be explaining to you the working of the program and also show you the output of the program.

What is a Palindrome Number?

When the digits are reversed, a palindromic number stays the same. It has reflectional symmetry along a vertical axis, to put it another way. The term palindromic comes from palindrome, which refers to a word with the same spelling when the letters are reversed. For example, the number 12321 is a palindrome number, but 1451 is not a palindrome number.

Examples of Palindrome Number:

Input: 1221
Output: True

Input: 146541
Output: False

Input: 5
Output: True

C# Program to check Palindrome number

Here’s the C# Program to check Palindrome number:

using System;
 
namespace CheckPalindrome
{
    class Program
    {
        static void Main(string[] args)
        {
            int num, n, reverseNo=0,r;
            Console.WriteLine("Enter the number :");
            num = Convert.ToInt32(Console.ReadLine());
            n = num;
            while(n!=0)
            {
                r = n % 10;
                reverseNo = reverseNo*10+r;
                n = n / 10;
            }
            if (num == reverseNo)
                Console.WriteLine("Entered number {0} is palindrome number", num);
            else
                Console.WriteLine("Entered number {0} is not a palindrome number", num);
 
            Console.ReadKey();
        }
    }
}

Output

Here’s the output of the above C# Program:

C# Program to check Palindrome number
groot
groot

Leave a Reply

Your email address will not be published. Required fields are marked *